Code

Opened 6 years ago

Closed 6 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: UI/UX:

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.

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by brosner

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

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.

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.