Closed
Description
save_form_data
with delete orphans is executing before validate
which means that orphans are deleted even if image validation fails. Outcome is that database still holds the old file name while the file is deleted.
# model
class ImageSample(models.Model):
image = StdImageField(
'main image',
delete_orphans=True,
blank=True,
validators=[
MinSizeValidator(500, 500),
],
help_text=_('Min image size is 500x500px.'),
)
# form
class SampleForm(forms.ModelForm):
class Meta:
model = ImageSample
fields = ['image']
- Upload valid image (i.e. https://via.placeholder.com/600x600 ) - all is good
- Now try to upload too small image (i.e. https://via.placeholder.com/200x200 ) - old file is deleted, validation kicks in, database still holds old file name
--
Tested on:
Django v2.2.19
django-stdimage v5.2.0, v5.2.1, v5.3.0