Django app deployment not loading static files

前端 未结 1 1631
梦如初夏
梦如初夏 2021-01-14 09:10

I have a django app which has angular and bootstrap. This is how my settings are defined:

# Django settings for studentsite project.
import os

PROJECT_DIR =         


        
相关标签:
1条回答
  • 2021-01-14 09:36

    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

    0 讨论(0)
提交回复
热议问题