I have a custom clean method:
def clean_image(self): image = self.cleaned_data['image'] if image: from django.core.files.images import get_image_dimensions w, h = get_image_dimensions(image) if not image.content_type in settings.VALID_IMAGE_FORMATS: raise forms.ValidationError(u'Only *.gif, *.jpg and *.png images are allowed.') if w > settings.VALID_IMAGE_WIDTH or h > settings.VALID_IMAGE_HEIGHT: raise forms.ValidationError(u'That image is too big. The image needs to be ' + str(settings.VALID_IMAGE_WIDTH) + 'px * ' + str(settings.VALID_IMAGE_HEIGHT) + 'px (or less).') return image
The problem scenario is as follows:
Uploaded image. Now I want to clear it using the checkbox that appears with the ImageField widget. When submitting a form to make it clear, clear does not.
If I remove my own clean method, clarity will work. Therefore, I assume that my method is doing something wrong.
source share