Changes between Initial Version and Version 1 of Ticket #32320


Ignore:
Timestamp:
Jan 5, 2021, 1:02:40 AM (4 years ago)
Author:
Mariusz Felisiak
Comment:

This is a documented behavior:

"The auto_now and auto_now_add options will always use the date in the default timezone at the moment of creation or update. If you need something different, you may want to consider using your own callable default or overriding save() instead of using auto_now or auto_now_add; or using a DateTimeField instead of a DateField and deciding how to handle the conversion from datetime to date at display time."

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #32320

    • Property Resolutioninvalid
    • Property Status newclosed
  • Ticket #32320 – Description

    initial v1  
    11Hi.
    22
    3 `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.
     3`django.db.models.fields.DateField(auto_now=True)` sets date as `datetime.date.today()` (see [https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L1246 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.
    44
    55Suggestion:
Back to Top