easy-thumbnails icon indicating copy to clipboard operation
easy-thumbnails copied to clipboard

`easy_thumbnails.singals.saved_file` signal is sent when 'FiledField.save()` is called

Open debanshuk opened this issue 8 years ago • 1 comments

This is happening because _commited attribute of a FildeField, which is checked here https://github.com/SmileyChris/easy-thumbnails/blob/2.3/easy_thumbnails/signal_handlers.py#L20 to send the saved_file signal is set to True in the save function (see: https://github.com/django/django/blob/1.9.7/django/db/models/fields/files.py#L89).

Django admin also seem to call the save the method of a FileField, as uploading a file from Django admin also doesn't trigger the save_file signal.

Following are two example to demonstrate the issue:

  • Following code would trigger the saved_file signal:
a_obj = ModalA.objects.get(pk=1)
a_obj.image_field = File(some_image_file)
a_obj.save()
  • But follwing code won't trigger the saved_file signal:
a_obj = ModalA.objects.get(pk=1)
a_obj.image_field.save('some_name.png', File(some_image_file), save=False)
a_obj.save()
# or `a_obj.image_field.save('some_name.png', File(some_image_file), save=True)`

debanshuk avatar Jul 14 '16 15:07 debanshuk

relates #186

fdemmer avatar Jul 16 '18 20:07 fdemmer