Opened 9 years ago

Closed 5 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:

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@… 9 years ago.
not extensively tested patch

Download all attachments as: .zip

Change History (6)

Changed 9 years ago by brice@…

not extensively tested patch

comment:1 Changed 8 years ago by hakejam

  • Needs documentation unset
  • Needs tests set
  • Owner changed from nobody to hakejam
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to 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 Changed 8 years ago by hakejam

  • Summary changed from ImageField and db_column don't do well to ImageField with db_column results in KeyError in Admin Edit

Changed title to better describe the problem.

comment:3 Changed 8 years ago by jacob

  • Triage Stage changed from Design decision needed to Accepted

comment:4 Changed 7 years ago by Gulopine

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 5 years ago by adamnelson

  • Resolution set to wontfix
  • Status changed from assigned to 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.

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