-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
Fixed #24281 -- Improved docs for timezone handling for auto_now and auto_now_add #4364
Fixed #24281 -- Improved docs for timezone handling for auto_now and auto_now_add #4364
Conversation
and convert to a date format for display only. | ||
|
||
``auto_now`` and ``auto_now_add`` become ambiguous as well. | ||
It's recommended to set a ``default`` value that does what you expect regarding timezones. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overriding save()
provides a better implementation of what users of auto_now(_add)
expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this comment? For auto now, only overriding save works. For auto now add, I'm not aware of any reason to prefer it over a default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right: default
works as a replacement for auto_now_add
— provided it's serializable by migrations.
I still find it better to document "override save()" than to get into a discussion of what is serializable by migrations and why default
can replace auto_now_add
but not auto_now
.
@chrisjluc Here's the wording that I would propose adding to the
@aaugustin does that seem like reasonable advice to you? |
@carljm That's almost correct. These options will always use the default time zone, which is defined by Otherwise, sounds great to me. |
Hmm, I thought I'd tested the other day and observed that |
Yep, I was wrong;
As Aymeric says, "default timezone" should link to https://docs.djangoproject.com/en/1.7/topics/i18n/timezones/#default-time-zone-and-current-time-zone - I didn't look up the Sphinx reference needed for that. |
This looks good to me. @chrisjluc can you squash it back down to one commit? |
374e77c
to
dec896d
Compare
@carljm the commits have been squashed. |
Fixed in 8119876. Thanks. |
https://code.djangoproject.com/ticket/24281