I want to upload one image(location of which stores in photo
field of model mentioned below ) and I want to duplicate that photo to another field thumbnail
programmatically.
I tried in the way mentioned in class Picture(models.Model):
below. Bytheway ResizedImageField
works and i have tested it only for the photo
field. Help needed to overwrite the def save(self, *args, **kwargs):
method mentioned below.
from django_resized import ResizedImageField
class Picture(models.Model):
photo = ResizedImageField('photo', upload_to='photos/%Y/%m/%d', size=[636,331])
thumbnail = ResizedImageField('thumbnail', upload_to='thumbnail/%Y/%m/%d', size=[150, 100], blank=True, null=True)
def save(self, *args, **kwargs):
super(Picture, self).save(*args, **kwargs)
if self.photo:
self.thumbnail = ResizedImageField(self.photo)
self.thumbnail.save()