[Django]-Django, retrieve image using url and save it ThumbnailerImageField of easy_thumbnails

3👍

from django.core.files.temp import NamedTemporaryFile
try:
    img_temp = NamedTemporaryFile(delete=True)
    img_temp.write(
        urllib2.urlopen(picture_url).read()
    )
    img_temp.flush()
    profile.picture.save('picture.jpg', File(img_temp))
    profile.save()
except:
    pass

Leave a comment