在我的设置.py你说
STATIC_ROOT = '/home/khantthulinn/webapps/static_media/'
STATIC_URL = '/home/khantthulinn/webapps/static_media/'
在我的网址.py你说
^{pr2}$之后,在我的web服务器中,我复制了静态文件。在
python manage.py collectstatic
一切都很好,我看得很对。在
当我更改DEBUG=False时,就会出现问题。在
我已经读过了,但我不明白。在
https://docs.djangoproject.com/en/1.10/howto/static-files/deployment/
我也从这里读过解决方案。在
Why does DEBUG=False setting make my django Static Files Access fail?
With debug turned off Django won't handle static files for you any more - your production web server (Apache or something) should take care of that.
我想试试。我该怎么办?在
我不想运行这个,因为它不安全。在
manage.py runserver --insecure
如果您使用的是apache和mod\wsgi,则需要更改
wsgi.py
文件。在您只需在文件末尾插入以下行:
from django.core.wsgi import get_wsgi_application from django.contrib.staticfiles.handlers import StaticFilesHandler application = StaticFilesHandler(get_wsgi_application())
注意,我使用的是django1.8(LTS),我不太确定这些函数是否仍在实际版本中。在
您必须为
/static
创建它们在本地的路径的别名。阅读以下答案:Django Static File Hosting an Apache
相关问题 更多 >
编程相关推荐