Opened 17 years ago

Closed 17 years ago

#6204 closed (invalid)

Key "created" not found in Form

Reported by: jesper@… Owned by: nobody
Component: Forms Version: newforms-admin
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

There's a bug in the newforms-admin code. Django uses newforms.models.form_for_instance to create forms in the admin interface. I've had errors on several fields, all of type date. I tracked down the bug, and for some reason, Django will skip over a field if it's not "editable", which I guess makes sense. The problem is that a field such as created = models.DateTimeField(auto_now_add=True, core=True) will not be editable, even if I set editable=True.

To get around it, I changed the line if not f.editable: in newforms.model line 116 to if not f.editable and not f.core:. This seems to do the trick, but it should be investigated further.

Change History (1)

comment:1 by Brian Rosner, 17 years ago

Resolution: invalid
Status: newclosed

auto_now_add is deprecated and should be replaced by using a callable to default. Ex. default=datetime.datetime.now. core has also been removed in newforms-admin so you shouldn't need to be using it any longer. Date fields that have auto_now_add or auto_now are *always* made to be editable=False. I would recommend removing the patch you did to Django and correct it the right way.

Note: See TracTickets for help on using tickets.
Back to Top