#7390 closed (invalid)
auto_now_add bug
Reported by: | Jeff Anderson | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
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 |
Description
Consider the following model:
class Ticket(Model):
name=SlugField()
class Comment(Models):
name=SlugField()
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 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 17 years ago
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 (default=datetime.now), 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.
auto_now_add is outdated.