Opened 11 years ago

Closed 8 years ago

#3601 closed (wontfix)

ImageField with db_column results in KeyError in Admin Edit

Reported by: brice@… Owned by: hakejam
Component: contrib.admin Version: master
Severity: Keywords: ImageField
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:


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/ 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)

django-patch-for-ticket3601.patch (410 bytes) - added by brice@… 11 years ago.
not extensively tested patch

Download all attachments as: .zip

Change History (6)

Changed 11 years ago by brice@…

not extensively tested patch

comment:1 Changed 11 years ago by hakejam

Needs tests: set
Owner: changed from nobody to hakejam
Status: newassigned
Triage Stage: UnreviewedDesign decision needed

Verified the problem still exists. The patch above works as advertised, although I have only tested in a simple case.

comment:2 Changed 11 years ago by hakejam

Summary: ImageField and db_column don't do wellImageField with db_column results in KeyError in Admin Edit

Changed title to better describe the problem.

comment:3 Changed 11 years ago by Jacob

Triage Stage: Design decision neededAccepted

comment:4 Changed 10 years ago by Marty Alchin

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 Changed 8 years ago by Adam Nelson

Resolution: wontfix
Status: assignedclosed

All of django/contrib/admin/view/ 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.

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