Friday, October 31, 2014

Auto-filling others ImageFields based on the original one

Hi,

I have to save 3 versions of uploaded photo (and i dont want to use solr) , original one and two which are resized versions of the original one.
I need  those two additional photos as ImageFields in my model , due to the fact that i want to use django ORM.

   
Class Post(model.Models):
    
    #...
    photo = models.ImageField(upload_to="photo_album")
    original_photo = models.ImageField(upload_to="photo_album/originals", null=True)
    thumbnail = models.ImageField(upload_to="photo_album/thumbnails", null=True)



I have tried overriding the save method 

 
    def save(self):
            
self.thumbnail.file = self.photo.file
            
self.original_photo.file = self.photo.file
            
super(Post, self).save()


But that is not working (why?).

Any advice on how to solve this is much appreciated. Thanks!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3907a3ed-3d39-4a07-8ab9-e80a9fe6b32e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment