Skip to content

Localize DateTime field representations #5677

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

Conversation

saturdayplace
Copy link

This pull request modifies fields.DateTimeField.to_representation() to check a new api_settings value, and localize the DateTime if the value is truthy.

I was surprised that DRF didn't do this already when the timezone for a request has been activated. Googling around brought me to people who are subclassing the DateTime field and adding this functionality, so I thought built-in localization of datetimes might be useful.

@carltongibson
Copy link
Collaborator

Hi @saturdayplace.

Can you explain how this is different from the behaviour added in #5435? (What are you trying to achieve here exactly?)

We need test cases and docs covering added behaviour.

Also the test suite ended up very broken from this change

I'm going to close this for now, as it looks to me as if #5435 already adds this, but I'm happy to re-open if not.

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

Successfully merging this pull request may close these issues.

2 participants