Skip to content
This repository was archived by the owner on Sep 28, 2025. It is now read-only.
This repository was archived by the owner on Sep 28, 2025. It is now read-only.

update how to print dictionaries to logs #436

@modernNeo

Description

@modernNeo

use

class UserEncoder(json.JSONEncoder):
    def default(self, z):
        if isinstance(z, datetime.datetime):
            return str(z)
        elif isinstance(z, Group):
            return str(z)
        else:
            return super().default(z)



print(json.dumps(model_to_dict(request.user), indent=4, sort_keys=True, cls=UserEncoder))
print(json.dumps(request.session.get('attributes', None), indent=4, sort_keys=True, cls=UserEncoder))

to print the dictionaries in the election apps to the logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions