0
我想通過Django管理站點上傳圖像。但它不工作,我已經安裝了PIL包。但它顯示:<django.core.files.storage.FileSystemStorage object at 0x8a92f0c>/mcDonalds.jpg
Django圖像上傳不起作用
from django.core.files.storage import FileSystemStorage
projectDirPath = path.dirname(path.dirname(__file__))
storeImageDir = FileSystemStorage(location=projectDirPath + '/couponRestApiApp/static')
storeImage = models.ImageField(upload_to=storeImageDir)
和靜態dir是empty..is我做錯了什麼......
首先,'upload_to'應爲dir的圖像的任何圖像直接設置爲上傳路徑或可調用(請參閱[文檔](https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to))。請參閱:http://stackoverflow.com/questions/5135556/dynamic-file-path-in-django。 – alecxe