Opened 28 hours ago
Last modified 23 hours ago
#36265 new New feature
Add support for serializing zoneinfo.ZoneInfo objects in migrations
Description ¶
in settings.py
USE_TZ = True
In models.py
class MyClass: timestamp = models.DateTimeField() date = models.GeneratedField( expression=TruncDate('timestamp', tzinfo=INDIA_TIMEZONE), output_field=models.DateField(), db_persist=True, )
makemigrations:
ValueError: Cannot serialize: zoneinfo.ZoneInfo(key='Asia/Kolkata')
date field is added after the table has already been created.
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Change History (2)
comment:1 by , 26 hours ago
comment:2 by , 23 hours ago
Summary: | Generated Field with TruncDate and tzinfo → Add support for serializing zoneinfo.ZoneInfo objects in migrations |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → New feature |
As zoneinfo.ZoneInfo
objects are not supported in migrations (see docs: https://docs.djangoproject.com/en/dev/topics/migrations/#migration-serializing), I have classed this as a new feature rather than a bug
Note:
See TracTickets
for help on using tickets.
Note for others trying to replicate: