我的部署脚本覆盖了媒体和源目录,这意味着我必须将上传目录移出媒体目录,并在提取上传文件后替换它.
My deployment script overwrites the media and source directories which means I have to move the uploads directory out of the media directory, and replace it after the upload has been extracted.
如何指示 django 上传到/uploads/而不是/media/?
How can I instruct django to upload to /uploads/ instead of /media/?
到目前为止,我不断收到 django 可疑操作错误!:(
So far I keep getting django Suspicious Operation errors! :(
我想另一种解决方案可能是符号链接?
I suppose another solution might be a symlink?
非常感谢,托比.
我做了以下:
from django.core.files.storage import FileSystemStorage
upload_storage = FileSystemStorage(location=UPLOAD_ROOT, base_url='/uploads')
image = models.ImageField(upload_to='/images', storage=upload_storage)
UPLOAD_ROOT 在我的 settings.py 文件中定义:/foo/bar/webfolder/uploads
UPLOAD_ROOT is defined in my settings.py file: /foo/bar/webfolder/uploads
这篇关于Django upload_to 在 MEDIA_ROOT 之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何在python中的感兴趣区域周围绘制一个矩形How to draw a rectangle around a region of interest in python(如何在python中的感兴趣区域周围绘制一个矩形)
如何使用 OpenCV 检测和跟踪人员?How can I detect and track people using OpenCV?(如何使用 OpenCV 检测和跟踪人员?)
如何在图像的多个矩形边界框中应用阈值?How to apply threshold within multiple rectangular bounding boxes in an image?(如何在图像的多个矩形边界框中应用阈值?)
如何下载 Coco Dataset 的特定部分?How can I download a specific part of Coco Dataset?(如何下载 Coco Dataset 的特定部分?)
根据文本方向检测图像方向角度Detect image orientation angle based on text direction(根据文本方向检测图像方向角度)
使用 Opencv 检测图像中矩形的中心和角度Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 检测图像中矩形的中心和角度)