我尝试了在django媒体文件夹中保存文件的最简单方法 这是我的.conf apache wsgi配置文件
ServerName testapplication.com
WSGIScriptAlias / /home/seba/git/CNBLUE/supergestor/supergestor/wsgi.py
WSGIPythonPath /home/seba/git/CNBLUE/supergestor
Alias /static /home/seba/git/CNBLUE/supergestor/static/
Alias /media /home/seba/git/CNBLUE/supergestor/media/
<Directory /home/seba/git/CNBLUE/supergestor/supergestor>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /home/seba/git/CNBLUE/supergestor/media/>
Require all granted
</Directory>
<Directory /home/seba/git/CNBLUE/supergestor/static/>
Require all granted
</Directory>
在我的settings.py文件中,我设置了MEDIA_ROOT =&#39; / home / seba / git / CNBLUE / supergestor / media /&#39;
和MEDIA_URL =&#39;&#39;
媒体文件夹位于我的项目文件夹的根目录,django项目是supergestor
当我尝试上传时我发现了这个错误[Errno 13]权限被拒绝:&#39; / home / seba / git / CNBLUE / supergestor / media&#39; 我没有头绪
答案 0 :(得分:0)
MEDIA_ROOT
应设置如下:
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
MEDIA_ROOT = os.path.join(BASE_DIR, "/media")
我建议您先检查目录权限。