ImageField/FileField behaviour on ModelForms
|Reported by:||sime||Owned by:||gabrielhurley|
|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)
Changed 7 years ago by sime
comment:1 Changed 7 years ago by sime
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Design decision needed
comment:3 Changed 4 years ago by gabrielhurley
- Owner changed from nobody to gabrielhurley
- Patch needs improvement set
- Status changed from new to assigned
- Triage Stage changed from Design decision needed to Accepted