hey damian,

thanks for replying. i'd like to save the thumbnail into a separate
field. i just found the save_fieldname_file() method using the shell.
so my model looks like this:

class Picture(models.Model):
        image = models.ImageField(upload_to="uploads", blank=True)
        thumbnail = models.ImageField(upload_to="uploads", blank=True)
        title = models.CharField(blank=True, maxlength=200, core=True)
        size = models.CharField(blank=True, maxlength=50)
        medium = models.CharField(blank=True, maxlength=50)
        date = models.CharField(blank=True, maxlength=4)

        def __str__(self):
                return self.title

        def save(self):
                super(Picture, self).save()
                if self.image and not self.thumbnail:
                        import Image
                        myImage = Image.open(self.get_image_filename())
                        myImage.thumbnail((150,150))
                        myName = 'th_' + 
self.get_image_filename().split('/')[-1]
                        self.save_thumbnail_file(myName, myImage)

does it make sense?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to