Opened 19 years ago

Closed 18 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

Description

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),
        meta.TextField('data','data'),
        meta.DateTimeField('date','date',auto_now_add=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 by Adrian Holovaty, 19 years ago

Resolution: invalid
Status: newclosed

We worked this out via IRC.

comment:2 by jbennett@…, 19 years ago

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 by jbennett@…, 19 years ago

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 by aCC, 19 years ago

@jbennett

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

comment:5 by oliver.andrich@…, 19 years ago

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 by Adrian Holovaty, 18 years ago

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