【发布时间】:2019-01-17 01:22:19
【问题描述】:
我有一个问题,我的 .css 文件不适用于 Django 中的 .html 文件。但是,例如,当我键入 . .html 文件中的一些类名,pycharm 让我完成类名。所以,我认为它是正确的。
不管怎样,我把我的设置文件放进去:
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
运行python manage.py collectstatic 成功并使用命令将我的 .css 文件添加到 .html:
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'base.css' %}"/>
在我的项目中,我有这样的东西:
-website
-static
-admin (generated when I run the command above)
-images
-base.css
-templates
-navbar.html
-base.html
-app1
-app2
-etc
出于测试目的,我只是将简单的 div 放在 .html 文件的头部:
<div class="example">jvhgbhjgf</div>
在 .css 文件中:
.example { background-color: red; border-radius: 15px;}
【问题讨论】:
标签: html css django django-templates django-staticfiles