Code

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7390 closed (invalid)

auto_now_add bug

Reported by: programmerq 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: UI/UX:

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.

Attachments (0)

Change History (2)

comment:1 Changed 6 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

auto_now_add is outdated.

comment:2 Changed 6 years ago by russellm

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.