Today I had experience with django file downloads from an specified url into Django model FileField. I'm writing content grabber from Flickr. I didn't find information about it and decided to write what I've discovered so far in example. Stackoverflow helped me a bit. But answer proposed there had not worked. So this is code example how to workout this issue: because code worth a thousand words :) We have a model with one field: #models.py class Photo ( models . Model ): image = models . ImageField ( 'Label' , upload_to = 'path/' ) We need to create a photo from image url and save it to the model's FileField. #somewhere in views.py # usually in header imports from urlparse import urlparse import urllib2 from django . core . files import File #add imprt of content file wrapper from django . core . files . base import ContentFile # somewhere: for e.g. in view handling the file operations photo = Photo () img_url =...
My thoughts/recipes on Django, Python, JS and other things I try...