Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Post(models.Model):
- #...
- photo = models.ImageField(upload_to="photo_album")
- thumbnail = models.ImageField(upload_to="photo_album/thumbnails", null=True, blank=True)
- def save(self):
- thumb = Image.open(self.photo.file)
- thumb_io = StringIO.StringIO()
- thumb.save(thumb_io,format = thumb.format,)
- self.thumbnail.save(self.photo.name, ContentFile(thumb_io.getvalue()), save=False)
- super(Post, self).save()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement