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

cast_type of DateTimePGPSymmetricKeyField does not allow for dumpdata exports exporting timezone aware datetimes. #307

Closed
steezeburger opened this issue Dec 24, 2020 · 3 comments · Fixed by #318

Comments

@steezeburger
Copy link

steezeburger commented Dec 24, 2020

Extremely easy to override with a custom class when using Postgres as your database

class CustomDateTimePGPSymmetricKeyField(fields.DateTimePGPSymmetricKeyField):
    """
    Overriding cast_type so `dumpdata` command exports timezone aware datetimes.
    """
    cast_type = 'TIMESTAMPTZ'

but maybe this could be a setting? Or it could look at current USE_TZ setting?

@peterfarrell
Copy link
Collaborator

@steezeburger

Django treats all datetimes with timezone so this likely a bug by using the wrong cast type. Ref:

https://docs.djangoproject.com/en/3.1/topics/i18n/timezones/#postgresql

I think we can safely change over to TIMESTAMPTZ without any ill effects given that is what Django always uses. A PR is welcome to fix this.

@steezeburger
Copy link
Author

Ah beat me to it! I forgot I forked this and fixed, but never got the tests running and forgot to submit the PR haha. Thanks for this!

@peterfarrell
Copy link
Collaborator

@steezeburger still need to do a release -- install from master if you want it today.

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

Successfully merging a pull request may close this issue.

2 participants