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

Concern about timezone #72

Open
sveetch opened this issue Nov 25, 2023 · 2 comments
Open

Concern about timezone #72

sveetch opened this issue Nov 25, 2023 · 2 comments
Labels
API Bug Something isn't working Question Further information is requested

Comments

@sveetch
Copy link
Member

sveetch commented Nov 25, 2023

Describe the bug
DjangoRestFramework apply current timezone to the datetime values in serializer fields. Concretely it applies the timezone defined in settings.TIMEZONE to datetimes in serializer payload.

Environment
Describe your environment:

  • Plateform: Any
  • Python version: Any
  • Django version: Any
  • Lotus version: Any

To Reproduce

However from serializers tests it seems that ArticleSerializer.publish_datetime() has no timezone applied from output serializer, this is because we use a SerializerMethodField for it so we don't have the serializers.DateTimeField behavior.

Expected behavior
All date should behave the same. We can apply the timezone in ArticleSerializer.publish_datetime() but it needs to copy the DRF one, that seem to be conditionned to settings.USE_TZ value.

Additional context
This should be a concern only in API, but view/templatetag code have to be inspected to check if they use something like isoformat() formatting which would transform date object in string, that Django would not be able to apply current timezone.

@sveetch sveetch added Bug Something isn't working Question Further information is requested API labels Nov 25, 2023
@sveetch
Copy link
Member Author

sveetch commented Nov 25, 2023

A change for this timezone problem has been made in a test for Category serializer after adding a new datetime field to the model:

d16d285#diff-12a026764140d30c3977c975c7c95b036237cf17d4bb6deac5b56b667938fbcfR159

@sveetch
Copy link
Member Author

sveetch commented Dec 1, 2023

It seems only Article publish_datetime serializer field is missing the timezone. There is also Article publish_time but i'm not sure it would need the timezone and maybe it is not useful to have the divided publish date and time in payload ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Bug Something isn't working Question Further information is requested
Projects
Status: To do
Development

No branches or pull requests

1 participant