简体   繁体   English

Django静态文件不显示在生产服务器中。 如何正确映射它们,以便可以看到管理GUI

[英]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? 也许我没有正确收集静态文件?

Picture of the page: 页面图片: 在此处输入图片说明

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.

相关问题 Mutagen:如何“正确”将专辑封面嵌入到 mp3 文件中,以便我可以看到 Pitcure 显示为文件图标 - Mutagen: How can I "correctly" embed album art into mp3 file so that I can see the pitcure display as file icon 我可以在 Django 的生产服务器上提供媒体文件吗? - Can i serve media files on production server in Django? 我如何在 django 中提供 static 文件? - How can i serve static files in django? 如何在 Django 管理站点中查看我的 MySQL 数据库? - How can I see my MySQL database in Django admin site? 在Django 1.8中,如何设置settings.py以便管理静态文件? - In Django 1.8, how can I set settings.py so that manage static files? 如何根据用户Django在django admin中显示表单 - How can I display form in django admin depending on user, Django 如何循环结果并将它们存储在列表中,以便我可以在我的Django模板中使用它们 - How do I loop through results and store them in a list so I can use them in my Django template 在 django 中,如果我想显示已上传到 model 的文件,如何单独显示每个文件? - In django if i want to display files which i've uploaded them to a model how can i display each one alone? 如何格式化 python 数据框超链接,以便我可以使用 Web 浏览器正确打开它们? - How can I format python data frame hyperlinks so I can correctly open them with web browser? 如何在Python APP之上创建GUI,以便它可以执行GUI或CLI? - How can I create a GUI on top of a Python APP so it can do either GUI or CLI?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM