Opened 18 years ago
Closed 18 years ago
#6204 closed (invalid)
Key "created" not found in Form
| Reported by: | 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.
auto_now_addis deprecated and should be replaced by using a callable todefault. Ex.default=datetime.datetime.now.corehas also been removed in newforms-admin so you shouldn't need to be using it any longer. Date fields that haveauto_now_addorauto_noware *always* made to beeditable=False. I would recommend removing the patch you did to Django and correct it the right way.