Django admin css 完美加载(状态:200)但输出显示纯 html 没有加载任何样式

Django admin css loads perfectly (status: 200) but the output shows pure html with no styles loaded

我是 Django 的新手,我一直在按照我发现的网站的步骤进行操作。 我已经尝试过我在其他问题上找到的解决方案,但 none 对我的情况有效。

Django Admin - Webpage

cmd output

Django Admin - Output no CSS

我的静态设置如下所示:

STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)


STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
#STATIC_ROOT = os.path.join(BASE_DIR, 'static')

我安装的应用设置如下所示:

DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'boards',
]

提前致谢!

编辑:

这是我正在加载的html:

{% load static %}<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Boards</title>
        <link rel="stylesheet" text="text/css" href="{% static 'myproject/css/bootstrap.css' %}">
    </head>
    <body>
        <div class="container">
            <ol class="breadcrumb my-4">
                <li class="breadcrumb item-active">Boards</li>
            </ol>
            <table class="table">
                <thead class="thead-inverse">
                    <tr>
                        <th>Board</th>
                        <th>Posts</th>
                        <th>Topics</th>
                        <th>Last Post</th>
                    </tr>
                </thead>
                <tbody>
                    {% for board in boards %}
                        <tr>
                            <td>
                                {{board.name}}<br>
                                <small class="text muted d-block">{{ board.description }}</small>
                            </td>
                            <td class="align-middle">0</td>
                            <td class="align-middle">0</td>
                            <td></td>
                        </tr>
                        {% endfor %}
                </tbody>
            </table>
        </div>
    </body>
</html>

在您的模板中,请像这样加载静态文件

{% load static %}