[Django] #24678: auto_add and auto_add_now cannot be used together in DateTimeField definition

199 views
Skip to first unread message

Django

unread,
Apr 21, 2015, 4:30:55 AM4/21/15
to django-...@googlegroups.com
#24678: auto_add and auto_add_now cannot be used together in DateTimeField
definition
-------------------------------------+-------------------------------------
Reporter: moritz.pfeiffer | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.8
(models, ORM) | Keywords: DateTimeField,
Severity: Normal | auto_now, auto_now_add
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
When I use auto_now=True in combination with auto_now_add=True on a
models.DateTimeField I get the following error:
python manage.py check:
(fields.E160) The options auto_now, auto_now_add, and default are mutually
exclusive. Only one of these options may be present.

See the attached project with a simple model illustrating this issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/24678>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 21, 2015, 4:32:02 AM4/21/15
to django-...@googlegroups.com
#24678: auto_add and auto_add_now cannot be used together in DateTimeField
definition
-------------------------------------------------+-------------------------

Reporter: moritz.pfeiffer | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.8
Severity: Normal | Resolution:
Keywords: DateTimeField, auto_now, | Triage Stage:
auto_now_add | Unreviewed

Has patch: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------------+-------------------------
Changes (by moritz.pfeiffer):

* Attachment "auto_now_add_test.zip" added.

Simple Django 1.8 project with a single model illustrating this issue

Django

unread,
Apr 21, 2015, 6:08:02 AM4/21/15
to django-...@googlegroups.com
#24678: auto_add and auto_add_now cannot be used together in DateTimeField
definition
-------------------------------------+-------------------------------------
Reporter: moritz.pfeiffer | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: DateTimeField, | Triage Stage:
auto_now, auto_now_add | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0


Comment:

Yes, this was indeed enforced in #21798. The error message is right, you
are not supposed to set both parameters. In your example use case,
`auto_now` is sufficient.

--
Ticket URL: <https://code.djangoproject.com/ticket/24678#comment:1>

Reply all
Reply to author
Forward
0 new messages