Opened 11 years ago

Closed 9 years ago

#1056 closed defect (fixed)

auto_now_add=True broken with ChangeManipulator

Reported by: GomoX <gomo@…> Owned by: nobody
Component: contrib.admin Version:
Severity: major Keywords:
Cc: gomo@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


This is from the current DateField definition (django/core/meta/

def pre_save(self, value, add):
    if self.auto_now or (self.auto_now_add and add):
    return value

When you modify an object that has this field using it's ChangeManipulator, the field gets set to "null" from the request, because the DateTime fields with auto_now_add=True or auto_now=True are not editable (line 387 of the same file).
An additional elif clause should be added to catch this problem, like this:

def pre_save(self, value, add):
    if self.auto_now or (self.auto_now_add and add):
    elif self.auto_now_add:
        return the_current_value_from_the_db
        return value

I'm posting the ticket instead of a patch because I'm not sure how to get the current value from the DB from the field instance.

Change History (4)

comment:1 Changed 11 years ago by Jacob

milestone: Version 1.0

This will likely become moot since auto_now_add should go away...

comment:2 Changed 10 years ago by (none)

milestone: Version 1.0

Milestone Version 1.0 deleted

comment:3 Changed 10 years ago by Gary Wilson <gary.wilson@…>

Triage Stage: UnreviewedAccepted

comment:4 Changed 9 years ago by Brian Rosner <brosner@…>

Resolution: fixed
Status: newclosed

Correct me if I am wrong, but since the removal of auto_now_add this isn't a problem in trunk. Reopen if I am incorrect.

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