Django模型FileField不存储数据库

时间:2019-04-26 04:41:44

标签: python django

  from django.core.files.storage import FileSystemStorage

  fs_photo = FileSystemStorage(location='/media/photos')
  fs_files = FileSystemStorage(location='/media/files')
 # this method i tried
 offer_letter = models.FileField(storage=fs_files,null=True)
 appraisal_letter = models.FileField(storage=fs_files,null=True)

#this method 
resume = models.FileField(upload_to='resume/',null=True)

#this method also i tried to save
offer_letter = 
models.FileField(upload_to='media/',blank=True,null=True)
# media path
MEDIA_ROOT = os.path.join(BASE_DIR, "media/")
MEDIA_URL ="/media/"
# in urls.py 

          ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

我正在尝试将文件保存到数据库中,但是没有保存,并且我的媒体路径也很完美。请帮我解决这个问题

0 个答案:

没有答案