我试图通过将引导文件夹从引导文件夹复制粘贴到静态文件夹来集成引导和Django。但我无法进入引导.css文件。显示404错误。我什么都照文件上说的做了,但运气不好。我正在使用django 2.x,但我也尝试了/static和<;%static%>;。你知道吗
.
├── blackowl
│ ├── blackowl
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── __init__.py
│ │ ├── migrations
│ │ │ └── __init__.py
│ │ ├── models.py
│ │ ├── __pycache__
│ │ │ ├── __init__.cpython-36.pyc
│ │ │ └── views.cpython-36.pyc
│ │ ├── tests.py
│ │ └── views.py
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-36.pyc
│ │ ├── settings.cpython-36.pyc
│ │ ├── urls.cpython-36.pyc
│ │ └── wsgi.cpython-36.pyc
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── db.sqlite3
├── index.html
├── manage.py
├── static
│ ├── bootstrap
│ │ ├── css
│ │ │ └── bootstrap.min.css
│ │ └── js
│ │ └── bootstrap.min.js
│ ├── css
│ │ ├── Login-Form-Dark.css
│ │ └── styles.css
│ ├── fonts
│ │ ├── ionicons.eot
│ │ ├── ionicons.min.css
│ │ ├── ionicons.svg
│ │ ├── ionicons.ttf
│ │ └── ionicons.woff
│ ├── img
│ │ └── star-sky.jpg
│ └── js
│ └── jquery.min.js
└── templates
└── index.html
在设置.py你知道吗
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/static/'
在索引.html你知道吗
<!DOCTYPE html>
{% load static %}
header
<link rel="stylesheet" href="{% static '/fonts/ionicons.min.css' %}">
图像
background: #475d62 url("{% static 'img/star-sky.jpg' %}");
在开发模式下,静态文件必须位于应用程序级目录中。 Django将在开发模式下提供静态文件时查看相应的应用程序目录
在您的情况下,将静态目录移动到
blackowl/blackowl
。你知道吗要从位于
css/styles.css
的css提供静态文件:使用静态文件的相对路径。你知道吗
此处包含的文档managing static files
相关问题 更多 >
编程相关推荐