Opened 10 years ago

Closed 10 years ago

#24678 closed Bug (invalid)

auto_add and auto_add_now cannot be used together in DateTimeField definition

Reported by: Moritz Pfeiffer Owned by: nobody
Component: Database layer (models, ORM) Version: 1.8
Severity: Normal Keywords: DateTimeField, auto_now, auto_now_add
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Attachments (1)

auto_now_add_test.zip (10.1 KB ) - added by Moritz Pfeiffer 10 years ago.
Simple Django 1.8 project with a single model illustrating this issue

Download all attachments as: .zip

Change History (2)

by Moritz Pfeiffer, 10 years ago

Attachment: auto_now_add_test.zip added

Simple Django 1.8 project with a single model illustrating this issue

comment:1 by Claude Paroz, 10 years ago

Resolution: invalid
Status: newclosed

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.

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