【发布时间】:2018-06-12 21:17:35
【问题描述】:
我正在尝试将一个 css 文件添加到我的 Django 应用程序中,最终投入生产,但现在我什至无法使用 runserver 让它运行本地服务器。每当我加载应该使用 css 文件的页面时,我都会收到错误 "GET /static/ldap/style.css HTTP/1.1" 404 1666,文件路径和错误代码有一些变化,因为我尝试了很多组合。我得到的其他一些错误是
"GET /static/style.css HTTP/1.1" 404 1651
Not Found: /ldap/style.css
[12/Jun/2018 15:07:07] "GET /ldap/style.css HTTP/1.1" 404 2804
我当前的设置正在尝试从 settings.py 文件中的 tutorial 和 suggested doc 复制官方文档。我有:
在我的 settings.py 中:
STATIC_URL = '/static/',
在我的 search.html 中:
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'ldap/style.css' %}">
因此,我的项目根文件夹的文件结构是(我试图在 ldap 应用程序中实现这一点,要清楚):
├── conf
├── db.sqlite3
├── djangoWrapper
│ ├── __init__.py
│ ├── __pycache__
│ ├── settings.py
│ ├── templates
│ │ └── djangoWrapper
│ │ └── index.html
│ ├── urls.py
│ ├── views.py
│ └── wsgi.py
├── ldap
│ ├── admin.py
│ ├── apps.py
│ ├── forms.py
│ ├── __init__.py
│ ├── migrations
│ ├── models.py
│ ├── static
│ │ └── ldap
│ │ └── style.css
│ ├── templates
│ │ └── ldap
│ │ ├── apiOffline.html
│ │ ├── index.html
│ │ ├── results.html
│ │ └── search.html
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── manage.py
├── openshift
├── README.md
├── requirements.txt
├── runserver.sh
└── static
└── admin
对于这里可能出现的问题有什么好的想法吗?我已经尝试关注很多其他相关的帖子(like this),但没有一个有效,这可能与它们都没有与我相同的错误代码(404 1666 和 404 1651)有关。我可以根据要求提供更多信息,不胜感激。谢谢。
【问题讨论】:
-
旁注:你用什么来制作这样的项目布局标记?
-
我使用了 cl 工具“树”。我不太了解它,因此不得不对其进行一些手动编辑,但它似乎很好地充实了做一些很好的东西的论据