码迷,mamicode.com
首页 > 其他好文 > 详细

上传文件

时间:2014-07-30 00:52:02      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:http   os   文件   io   for   ar   new   amp   

For example, the following code will store uploaded files under /media/photos regardless of what your
MEDIA_ROOT setting is:
from django.db import models
from django.core.files.storage import FileSystemStorage
fs = FileSystemStorage(location=’/media/photos’)
class Car(models.Model):
...
photo = models.ImageField(storage=fs)

 

else:

MEDIA_ROOT = ‘static/media/images/‘

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = ‘/static/media/images/‘

 

img = models.ImageField(upload_to=‘upload/news/%Y/%m/%d‘, blank=True, null=True)

上传文件,布布扣,bubuko.com

上传文件

标签:http   os   文件   io   for   ar   new   amp   

原文地址:http://www.cnblogs.com/tuifeideyouran/p/3876790.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!