Opened 4 years ago

Last modified 4 years ago

#32320 closed Bug

DateField uses unlocalized function when auto_now is True — at Initial Version

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

Hi.

django.db.models.fields.DateField(auto_now=True) sets date as datetime.date.today() (see [here](https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L1246)). 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 (0)

Note: See TracTickets for help on using tickets.
Back to Top