ImageField/FileField behaviour on ModelForms
|Reported by:||sime||Owned by:||Gabriel Hurley|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
When an ImageField is left blank on a ModelForm, and the underlying instance already has an image, the image remains. It isn't overwritten with None (removed).
This behaviour is good design :-) But it isn't documented, it isn't consistent with the behaviour of the other fields, and it doesn't provide a way of removing an image (I recall this was a problem with admin, not sure if it still is).
I suggest we add a note to the ModelForms doc to let people know that blank ImageFields won't remove existing images. Also, we might want to consider automatically adding an extra non-required BooleanField to the ModelForm, maybe remove_FIELDNAME.
Change History (5)
comment:3 Changed 7 years ago by
|Owner:||changed from nobody to Gabriel Hurley|
|Patch needs improvement:||set|
|Status:||new → assigned|
|Triage Stage:||Design decision needed → Accepted|