#32320 closed Bug (invalid)
DateField uses unlocalized function when auto_now is True
| Reported by: | M1ha Shvn | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Normal | Keywords: | auto_now DateField USE_TZ |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Hi.
django.db.models.fields.DateField(auto_now=True) sets date as datetime.date.today() (see here). This date is not localized with django and can be different from django.utils.timezone.now() used in DateTimeField, if django and local timzeones differ.
Suggestion:
Change datetime.date.today() to django.utils.timezone.now().date()
Change History (2)
comment:1 by , 5 years ago
| Description: | modified (diff) |
|---|---|
| Resolution: | → invalid |
| Status: | new → closed |
comment:2 by , 5 years ago
Also, unlike DateTimeField, DateField isn't timezone-aware. See a pull request thread where the change you suggested was proposed.
Note:
See TracTickets
for help on using tickets.
This is a documented behavior: