Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#7390 closed (invalid)

auto_now_add bug

Reported by: Jeff Anderson Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Consider the following model:

class Ticket(Model):


class Comment(Models):

ticket = models.ForeignKey(Ticket, edit_inline=TABULAR, num_in_admin=1)
timestamp = DateTimeField(auto_now_add=True)

When I edit a Ticket that has one or more comments already, when I hit save I get the error: myproj_comment.timestamp may not be NULL

It appears that the inline editing in the admin doesn't honor the "auto_now_add=True" option. I can edit or create a comment directly without problem.

The workaround I've done is to simply override the save() method and set timestamp to now() if it doesn't exist.

Change History (2)

comment:1 Changed 11 years ago by anonymous

Resolution: invalid
Status: newclosed

auto_now_add is outdated.

comment:2 Changed 11 years ago by Russell Keith-Magee

For the archives - this is the right result, for the wrong reason.

I don't know who anonymous is, but auto_now_add hasn't been deprecated yet. There has been talk about deprecating, and there is a better way (, but for the moment, auto_now_add is still a valid option.

However, the ticket is still wontfix. The error lies in the edit_inline functionality of trunk admin. edit_inline is known to have many problems in trunk admin, and we aren't fixing them - we're replacing trunk admin with newforms admin.

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