[英]Django 3 TemplateSyntaxError: 'css/bootstrap.min.css' is not a registered tag library
I added bootstrap.min.css
to my simple Django v3 project.我将
bootstrap.min.css
8CBA22E28EB17B5F5C6AE2A266AZ 添加到我的简单 Django v3 项目中。 So my home.html
is something like so:所以我的
home.html
是这样的:
{% load static %}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Boards</title>
<link rel="stylesheet" href="{% load static '/css/bootstrap.min.css' %}">
</head>
<body>
<div class="container">
<ol class="breadcrumb my-4">
<il class="breadcrumb-item active">Boards</il>
</ol>
<table class="table">
<thead class="thead-dark">
<tr>
<th>Boards</th>
<th>Posts</th>
<th>Topics</th>
<th>Last Post</th>
</tr>
</thead>
<tbody>
{% for each in boardlist %}
<tr>
<td>
{{ each.name }}
<small class="text_muted d-block">{{ each.description }}</small>
</td>
<td class="align-middle">0</td>
<td class="align-middle">0</td>
<td></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</body>
</html>
And my project structure is:我的项目结构是:
$ tree -I "*.pyc" forum/
forum/
├── boards
│ ├── admin.py
│ ├── apps.py
│ ├── __init__.py
│ ├── migrations
│ │ ├── 0001_initial.py
│ │ ├── __init__.py
│ │ └── __pycache__
│ ├── models.py
│ ├── __pycache__
│ ├── static
│ │ └── css
│ │ └── bootstrap.min.css
│ ├── templates
│ │ ├── home.html
│ │ └── home.html.bak
│ ├── tests.py
│ └── views.py
├── database
│ └── db.sqlite3
├── forum
│ ├── asgi.py
│ ├── __init__.py
│ ├── __pycache__
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── manage.py
10 directories, 18 files
But at the end when I run project I have the following error:但是最后当我运行项目时,出现以下错误:
django.template.exceptions.TemplateSyntaxError: ''/css/bootstrap.min.css'' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
bootstrap_tags
cache
i18n
l10n
log
static
tz
I am doubtful about my setting.py
which I have:我对我的
setting.py
怀疑态度:
STATICFILES_DIRS = [
#os.path.join(BASE_DIR, "boards","static"),
os.path.join(BASE_DIR, "static"),
'/var/www/static/',
]
# STATIC_URL = 'boards/static/'
STATIC_URL = '/static/'
But all possibilities are not working for me.但是所有的可能性都不适合我。
change this改变这个
<link rel="stylesheet" href="{% load static '/css/bootstrap.min.css' %}">
to至
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.