easy-thumbnails
easy-thumbnails copied to clipboard
Better `saved_file` documentation
When saved_file signal actually fires was the confusion in #185.
Docs should clearly show that this signal only fires when an uncommitted file is attached to the model and then the model is saved.
How do you attach an uncommitted file to a model?
This sample code is what I'm currently using. I am sure this is an incorrect usage of the API. I had to manually set the _committed flag to false and hardcode the path 'temp/Earth_from_Space.gif' to make the saved_file signal get sent. How would you write this code correctly?
# Profile.photo is a ``ThumbnailerImageField``
from easy_thumbnails.files import ThumbnailerImageFieldFile
profile = Profile.objects.get(pk=1)
file_field = dict([(x.name, x) for x in profile._meta.fields])['photo']
t = ThumbnailerImageFieldFile(profile, file_field, 'temp/Earth_from_Space.gif')
t._committed = False
profile.photo = t
profile.save()