On 1/11/2014 2:35 AM, Sasa Trifunovic wrote:
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
|
|
defsave(self):
self.thumbnail.file =self.photo.file
self.original_photo.file =self.photo.file
super(Post,self).save()
|
|
But that is not working (why?).
Try ...
def save(self, *args, **kwargs):
self.thumbnail.file = self.photo.file
self.original_photo.file = self.photo.file
super(Post,self).save(*args, **kwargs)
The args and kwargs are ORM params used to control saving. You need to
pass them back to the built-in save() method.
Good luck
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+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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
<https://groups.google.com/d/msgid/django-users/3907a3ed-3d39-4a07-8ab9-e80a9fe6b32e%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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+unsubscr...@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/54543A69.4030403%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.