Django app deployment not loading static files

青春壹個敷衍的年華 提交于 2019-12-01 10:59:21

Django's runserver serves static files through python automatically, which is not good enough for production use. When you deploy and are thus not using runserver, your static files are not auto-served.

In production, you must run the python manage.py collectstatic command which moves all static files to your settings.STATIC_ROOT.

You then need to serve settings.STATIC_ROOT at settings.STATIC_URL via your web server of choice, very commonly nginx as a reverse proxy behind your Apache-mod_wsgi app server.

You can also use your Apache, where you'd want to look into the <Directory> directive.

The documentation you linked to explains exactly what you need to do, and hopefully my bullet points make it a little easier to understand.

https://docs.djangoproject.com/en/dev/howto/deployment/wsgi//modwsgi/#serving-files

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