[英]Django static files do not display in production server. How can I map them correctly, so I can see the admin GUI
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. 我正在从Ubuntu Server 14.04运行django项目,网页已启动并正在运行,但是在页面加载时,没有CSS或根本没有格式,它看起来像纯HTML。 I know for sure that the admin page has a style and aesthetic, and even that looks like plain HTML.
我肯定知道管理页面具有样式和美感,甚至看起来像纯HTML。 What did I do wrong?
我做错了什么? Maybe I didn't collect the static files correctly?
也许我没有正确收集静态文件?
Not sure why this is happening 不知道为什么会这样
Apache error.log: Apache error.log:
did you set the STATIC_ROOT in your projects settings , then make collect static and add the folder name in apache conf. 您是否在项目设置中设置了STATIC_ROOT,然后将collect设置为static并在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 然后,如果运行python manage.py collect static,则该命令将创建一个名为“静态存储”的文件夹,所有样式(包括admin css等)将从静态文件夹复制,然后将根目录放入apache conf中的静态存储
I realized that I was mapping the static files incorrectly in apache.conf 我意识到我在apache.conf中错误地映射了静态文件
The correct map to the files would be: Alias /static /var/www/html/myproject/static
到文件的正确映射为:
Alias /static /var/www/html/myproject/static
Note : Need to make sure that /static
doesn't have a trailing slash in the above command 注意 :需要确保
/static
在上面的命令中没有斜杠
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.