Opened 18 years ago
Closed 15 years ago
#3601 closed (wontfix)
ImageField with db_column results in KeyError in Admin Edit
Reported by: | Owned by: | hakejam | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | ImageField | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi,
I seem to have stumbled upon a bug with ImageField.
Here are the steps to reproduce :
- define a model with an ImageField that has a db_column attribute that is different from his attribute name
- add an object of this class using the admin
- try to access the change_form of this object again and you should see a KeyError
If I understand correctly, the problem is located at line 136 of django/contrib/admin/view/main.py where we try to access self.original.dict[self.field.column], which doesn't exist.
My patch simply return self.original.dict[self.field.attname] instead.
Please note that this hasn't been extensively tested and I really don't have the needed time to add unit tests.
Attachments (1)
Change History (6)
by , 18 years ago
Attachment: | django-patch-for-ticket3601.patch added |
---|
comment:1 by , 17 years ago
Needs tests: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Triage Stage: | Unreviewed → Design decision needed |
Verified the problem still exists. The patch above works as advertised, although I have only tested in a simple case.
comment:2 by , 17 years ago
Summary: | ImageField and db_column don't do well → ImageField with db_column results in KeyError in Admin Edit |
---|
Changed title to better describe the problem.
comment:3 by , 17 years ago
Triage Stage: | Design decision needed → Accepted |
---|
comment:4 by , 16 years ago
I've verified manually that the newforms-admin has resolved this issue, but I'd rather see some tests to verify that it doesn't creep up again before I'd be comfortable calling this closed.
comment:5 by , 15 years ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
All of django/contrib/admin/view/main.py has been totally refactored since this ticket was opened and nobody has observed this in nearly 3 years. I haven't confirmed if it's an issue or not anymore but I presume somebody would have chimed in since 1.0 if there were problems with this. Feel free to reopen.
not extensively tested patch