Skip to content

Instantly share code, notes, and snippets.

@prestontimmons
Created April 27, 2011 21:31
Show Gist options
  • Save prestontimmons/945264 to your computer and use it in GitHub Desktop.
Save prestontimmons/945264 to your computer and use it in GitHub Desktop.
Saving an image to a Django model from a url
try:
contents = urllib2.urlopen(url).read()
except urllib2.HTTPError, exc:
# handle exception
pass
mymodel.image.save(file_name, ContentFile(contents))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment