Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User IDs that are UUID are converted to Integer in the log #17

Open
bystander58 opened this issue Feb 3, 2021 · 2 comments
Open

User IDs that are UUID are converted to Integer in the log #17

bystander58 opened this issue Feb 3, 2021 · 2 comments

Comments

@bystander58
Copy link

Since the output is for a log (display only), would it make better sense to change "IntegerField" to "CharField" in (storages.py)?

class UserSerializer(serializers.Serializer):
    id = serializers.IntegerField()
    username = serializers.CharField()
@leogregianin
Copy link
Contributor

I believe it makes more sense to keep the default as it is and you create a custom LogEntrySerializer by extending BaseEntrySerializer and id field with CharField() type.

class LogEntrySerializer(serializers.Serializer):
    class ResponseSerializer(serializers.Serializer):
        status_code = serializers.IntegerField(read_only=True)
        data = JsonDumpField(read_only=True)

    class UserSerializer(serializers.Serializer):
        id = serializers.CharField()
        username = serializers.CharField()

    action_name = serializers.CharField(read_only=True)
    execution_time = serializers.DurationField(read_only=True)
    timestamp = serializers.DateTimeField(read_only=True)
    ip_address = serializers.CharField(read_only=True)
    request = BaseRequestSerializer(read_only=True)
    response = ResponseSerializer(read_only=True)
    user = UserSerializer()

and change SERIALIZER_CLASS settings to:

REQUESTLOGS = {
    ...
    'SERIALIZER_CLASS': 'app.serializers.LogEntrySerializer',
    ...
}

@Raekkeri
Copy link
Owner

Thanks for providing the example, @leogregianin

Closing this issue soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants