django file upload: [Errno 13] Permission denied: '/static'

こ雲淡風輕ζ 提交于 2019-12-03 14:31:42

Your Apache configuration for the uploaded media:

Alias /media /var/www/webpage/webpage/

is not in-sync with your Django settings:

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = ''

# 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 = ''

Based on your Apache configuration you should have MEDIA_ROOT = '/var/www/webpage/webpage/' and MEDIA_URL = '/media/'.

You need to change the ownership of the static folder. With root user try "sudo chown -R yourusername:yourusername /projectfolder/static".

had the same error when I did

  python manage.py collectstatic

static_url and static_root have the same path in this case ' '

chose different directories and try again if you get this error

that fixed my problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!