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

add support for working with pytz object field #717

Merged

Conversation

MilanPecov
Copy link
Contributor

When a pytz object is serialized it fails with this error

TypeError: Object of type Africa/Abidjan is not JSON serializable and this issue has already been reported (for example #248)

The current workaround is to modify the methods in the pytz serializer field, but it becomes more complicated when other third party libraries in the project are also broken because of this.

So I think it is reasonable to assume that because any bigger real project will require working with a timezone, it's better to fix the problem here instead of making modifications on various fields and libraries. And it's just a few lines fix.

Also I'm not sure if this change requires tests and if they are needed where should I add them?

Thanks

@JoelLefkowitz JoelLefkowitz added the enhancement Enhancement proposal label Sep 22, 2021
@JoelLefkowitz JoelLefkowitz changed the base branch from master to 1.20.x September 22, 2021 16:38
@MilanPecov
Copy link
Contributor Author

I would also label this a bug because when a pytz object is serialized the docs are not working at all

@JoelLefkowitz JoelLefkowitz added bug Bug report/fix 1.21.x Release target in 1.21.x labels Jul 17, 2022
@JoelLefkowitz JoelLefkowitz changed the base branch from 1.20.x to 1.21.x July 17, 2022 17:13
@JoelLefkowitz
Copy link
Collaborator

@MilanPecov I agree this is good idea. If the user doesn't want the pytz objects to be parsed to strings they still have the option to modify the serializer. If there are other common field types that are limiting json encoding then we may need a separate method to handle them.

@JoelLefkowitz JoelLefkowitz merged commit 13f0af2 into axnsan12:1.21.x Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.x Release target in 1.21.x bug Bug report/fix enhancement Enhancement proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants