django imagefield

a guest Nov 8th, 2014 210 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Post(models.Model):
  2.     #...
  3.     photo = models.ImageField(upload_to="photo_album")
  4.     thumbnail = models.ImageField(upload_to="photo_album/thumbnails", null=True, blank=True)
  6.     def save(self):
  7.         thumb =
  8.         thumb_io = StringIO.StringIO()
  9.,format = thumb.format,)
  10., ContentFile(thumb_io.getvalue()), save=False)
  11.         super(Post, self).save()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand