问题
I am running a django project off of an Ubuntu Server 14.04, the web page is up and running, however when the page loads, there is no CSS, or format at all, it just looks like plain HTML. I know for sure that the admin page has a style and aesthetic, and even that looks like plain HTML. What did I do wrong? Maybe I didn't collect the static files correctly?
Picture of the page:
Not sure why this is happening
Apache error.log:
回答1:
did you set the STATIC_ROOT in your projects settings , then make collect static and add the folder name in apache conf.
eg :
STATIC_URL = '/static/'
STATIC_ROOT = root("statticstorage")
then if run python manage.py collect static the command will create a folder called static storage and all the styles (including admin css and etc) will copied from static folder , then make the root in to static storage in apache conf
回答2:
I realized that I was mapping the static files incorrectly in apache.conf
The correct map to the files would be:
Alias /static /var/www/html/myproject/static
Note: Need to make sure that /static
doesn't have a trailing slash in the above command
来源:https://stackoverflow.com/questions/37313485/django-static-files-do-not-display-in-production-server-how-can-i-map-them-corr