Skip to content

Delete orphans is executing before validation #229

@IgorCode

Description

@IgorCode

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']
  1. Upload valid image (i.e. https://via.placeholder.com/600x600 ) - all is good
  2. 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

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy