0

I added bootstrap.min.css to my simple Django v3 project. So my home.html is something like so:

{% 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:

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.

1 Answer 1

1

change this

<link rel="stylesheet" href="{% load static '/css/bootstrap.min.css' %}">

to

<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.