Hi, I'm trying to save a thumbnail image when I save a picture in one of my models. But I have three problems.
1. I can successfully create the thumbnail image, but I cannot link it in my database. 2. Is there a better way to name the thumbnail image? 3. When the save function is called, the image is already save to disk using the name of the original. Is it posible to use the self.name as the image name? Here is my model class : class ProductImage(models.Model): name = models.CharField(max_length=50) file = models.ImageField(upload_to="static/uploadto/prod_images") file_thumbnail = models.ImageField(upload_to="static/uploadto/ prod_images", blank=True, null=True) file_size = models.IntegerField(blank=True, null=True) keyword = models.CharField(max_length=50, blank=True, null=True) product = models.ForeignKey(Product) def __unicode__(self): return self.name def save(self, size=(60, 20)): if self.file: filename = self.file.path self.file_size = int(os.path.getsize(filename)) image = Image.open(filename) image.thumbnail(size) image.save(settings.MEDIA_ROOT + "/static/uploadto/ prod_images/" + str(self.file.name.split('.')[0].split("/")[-1]) + str("_tn.jpg"), 'JPEG') self.file_thumbnail = image super(ProductImage, self).save() --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---