Skip to content

Instantly share code, notes, and snippets.

@abithyzis
abithyzis / url2imagefield.py
Created February 16, 2016 12:31
Django AppEngine compatible url to ImageField
import requests
from StringIO import StringIO
from django.core.files.uploadedfile import InMemoryUploadedFile
response = requests.get(url)
img_io = StringIO(response.content)
thumb_file = InMemoryUploadedFile(img_io, None, file_name, 'image/jpeg', img_io.len, None)
new_video = Video()
new_video.thumb.save(file_name, thumb_file)
$('tr td:nth-child(2)').map(function() {
return $(this).text();
}).get().join(',')