1) django 上传图片
class CachedImage(models.Model):
url = models.CharField(max_length=255, unique=True)
photo = models.ImageField(upload_to=photo_path, blank=True)
def cache(self):
"""Store image locally if we have a URL"""
if self.url and not self.photo:
result = urllib.urlretrieve(self.url)
self.photo.save(
os.path.basename(self.url),
File(open(result[0]))
)
self.save()
http://stackoverflow.com/questions/1308386/programmatically-saving-image-to-django-imagefield
2. 上传下载大文件
https://djangosnippets.org/snippets/365/
3.API 文档
https://docs.djangoproject.com/en/1.7/ref/