ImageField with db_column results in KeyError in Admin Edit
|Reported by:||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)
comment:1 Changed 10 years ago by
|Owner:||changed from nobody to hakejam|
|Status:||new → assigned|
|Triage Stage:||Unreviewed → Design decision needed|
comment:2 Changed 10 years ago by
|Summary:||ImageField and db_column don't do well → ImageField with db_column results in KeyError in Admin Edit|