Opened 13 years ago

Closed 13 years ago

#89 closed defect (fixed)

DateTimeFields with auto_now_add = True in admin

Reported by: philippe.normand@… Owned by: Adrian Holovaty
Component: contrib.admin Version: 1.1
Severity: minor Keywords: date
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Expose a DateTimeField with auto_now_add = True to the admin, try to add a new object. You can see the date field with empty values (no calendar, etc). Save the object, you'll get a validation error.

Example model:

class Article(meta.Model):
    fields = (
        meta.CharField('title', 'title', maxlength=200, core=True),

    admin = meta.Admin(
        fields = (
            (None, {'fields': ('title', 'date','data',)}),

If i un-expose the 'date' field from admin, everything works fine.

Change History (6)

comment:1 Changed 13 years ago by Adrian Holovaty

Resolution: invalid
Status: newclosed

We worked this out via IRC.

comment:2 Changed 13 years ago by jbennett@…

Would it be possible to get the resolution of this issue, or at least a helpful summary, posted here in the ticket? The IRC log site is unreachable at the moment, so there's currently no way to find out how this was solved.

comment:3 Changed 13 years ago by jbennett@…

I finally was able to pull up the IRC log; the solution, apparently, was to use 'default=meta.LazyDate()' instead of 'auto_now_add=True'. In which case, shouldn't the model documentation reflect this, at least until auto_now_add works as advertised?

comment:4 Changed 13 years ago by aCC


Thanks a lot for digging this up! Finally it works like it should.

comment:5 Changed 13 years ago by oliver.andrich@…

Resolution: invalid
Status: closedreopened

I can understand the logic behind making the fields not editable when auto_now_add and auto_now are used, but then it shouldn't also be possible to use the fields inside the fields parameter inside a meta.Admin() call.

Or even better, I would highly appreciate to get them displayed read only. I don't want to change them, but I want to look at them. The admin interface is/should be a management console and not just an "item creation" workbench. At least this is what I understood.

comment:6 Changed 13 years ago by Adrian Holovaty

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.
Back to Top