-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Add failing test for to_representation with explicit default timezone #5821
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 failing test for to_representation with explicit default timezone #5821
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. This looks like a different issue. At first glance I’d think you want be setting the active time zone, rather than trying to set it on the field...
I haven't considered setting the timezone - it might have been easier than replacing DateTimeField with a SerializerMethodField. Either way I think the current behaviour is unexpected. I think it's reasonable to expect this snippet:
to produce the date in Asia/Kolkata and not UTC as it is now. |
Current behavior is consistent with Django's |
Fair enough. I'll close the PR. |
Following @carltongibson advice, is this also exepcted behaviour:
The rendered date is not in the current timezone (kolkata):
|
It looks like the timezone is only enforced for ISO 8601. |
@hakib Can you push that test as is. We'll have a look. |
That's exactly the point - right now it's not possible to provide a format other than ISO-8601 and have the date render in a timezone other than the default one. Just to clarify on the use case here, i'm usually working with UTC so I never noticed it. In this particular scenario I had a custom renderer aimed at a printer so I needed to make sure the date is rendered at the client's local time. |
See discussion here:
#5435 (comment)
Note: Before submitting this pull request, please review our contributing guidelines.
Description
Please describe your pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. When linking to an issue, please use
refs #...
in the description of the pull request.