我正在尝试将静态文件加载到我的html文件中。索引.html延伸基本.html. 但是,文件不会被读取(至少不会显示在屏幕上,但是终端不会说找不到)
在…的头上索引.html以及基本.html,我有一个标签
{% load static %}
我使用中的标记读取.css文件索引.html地址:
{% static 'base/css/style.css' %}
在设置.py,我有:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['Grace/templates/',
'HomePage/templates/',
'Forum/templates/',
'CustomUser/templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.csrf',
],
},
},
]
我的项目结构如下:
|Grace
|--static
|----base
|------css
|--------boostrap.min.css
|--------style.css
|------templates
|--------base.html
|Homepage
|--templates
|----index
|------index.html
提前谢谢!你知道吗
请尝试执行以下步骤:
假设这是您的目录:
在
settings.py
文件中,您必须指定名为static
的静态文件所在文件夹的路径,在我的示例中:而不是在任何
html
文件中,您可以像这样加载boostrap.css
文件:相关问题 更多 >
编程相关推荐