Django

Code

Ticket #89 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

DateTimeFields with auto_now_add = True in admin

Reported by: philippe.normand@gmail.com Assigned to: adrian
Component: Admin interface Version: 1.1
Keywords: date Cc:
Triage Stage: Unreviewed Has patch: 0
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 0

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.

Attachments

Change History

07/19/05 14:42:32 changed by adrian

  • status changed from new to closed.
  • resolution set to invalid.

We worked this out via IRC.

08/14/05 01:29:36 changed by jbennett@roanoke.edu

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.

08/14/05 16:33:13 changed by jbennett@roanoke.edu

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?

08/29/05 13:53:13 changed by aCC

@jbennett

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

09/07/05 09:25:20 changed by oliver.andrich@gmail.com

  • status changed from closed to reopened.
  • resolution deleted.

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.

04/23/06 17:52:28 changed by adrian

  • status changed from reopened to closed.
  • resolution set to fixed.

Add/Change #89 (DateTimeFields with auto_now_add = True in admin)




Change Properties
Action