Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Better `saved_file` documentation #186

Open
SmileyChris opened this Issue · 1 comment

2 participants

@SmileyChris
Owner

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.

@hekevintran

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.