ImageField with db_column results in KeyError in Admin Edit
|Reported by:||brice@…||Owned by:||hakejam|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||no|
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.
Change History (6)
Changed 7 years ago by brice@…
comment:1 Changed 7 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
comment:2 Changed 7 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