Opened 17 years ago

Closed 14 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: 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)

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

Download all attachments as: .zip

Change History (6)

by brice@…, 17 years ago

not extensively tested patch

comment:1 by hakejam, 17 years ago

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 by hakejam, 17 years ago

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 by Jacob, 16 years ago

Triage Stage: Design decision neededAccepted

comment:4 by Marty Alchin, 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 Adam Nelson, 14 years ago

Resolution: wontfix
Status: assignedclosed

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.

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