Если кто-нибудь может мне помочь, почему мой html не связывается с моим css, это было бы здорово! Спасибо! Я использую Django 3.0.2 для создания веб-сайта для резюме, и я уже укоренил свои stati c файлы, и это, похоже, ничего не сделало. Я несколько раз пытался остановить и запустить свой сервер, а также найти решения в Интернете, но все используют более старую версию, или их решения не помогают.
HTML:
<head>
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static '/base/styles.css' %}">
</head>
<body>
this is a test
<div class="container">
<header>
{% include 'navbar.html' %}
</header>
</div>
</body>
CSS:
body {
background-color: rgb(82, 70, 70);
}
.container{
background-color: rgb(128, 199, 172);
}
.navbar{
background-color: rosybrown;
}
НАСТРОЙКИ:
STATICFILES_DIR = [
os.path.join(BASE_DIR, 'static'),
'/pydir/mysite/static',
]
STATIC_ROOT = '/pydir/mysite/static'
STATIC_URL = '/static/'
и я убедился, что staticfiles и admin находятся в установленных приложениях.
СТРУКТУРА ПАПКИ:
├───mysite
│ │ asgi.py
│ │ settings.py
│ │ urls.py
│ │ wsgi.py
│ │ __init__.py
│ │
│ └───__pycache__
│ settings.cpython-37.pyc
│ urls.cpython-37.pyc
│ wsgi.cpython-37.pyc
│ __init__.cpython-37.pyc
│
├───pages
│ │ admin.py
│ │ apps.py
│ │ models.py
│ │ tests.py
│ │ views.py
│ │ __init__.py
│ │
│ ├───migrations
│ │ __init__.py
│ │
│ └───__pycache__
│ views.cpython-37.pyc
│ __init__.cpython-37.pyc
│
├───projects
│ │ admin.py
│ │ apps.py
│ │ models.py
│ │ tests.py
│ │ views.py
│ │ __init__.py
│ │
│ ├───migrations
│ │ │ 0001_initial.py
│ │ │ __init__.py
│ │ │
│ │ └───__pycache__
│ │ 0001_initial.cpython-37.pyc
│ │ __init__.cpython-37.pyc
│ │
│ └───__pycache__
│ admin.cpython-37.pyc
│ models.cpython-37.pyc
│ __init__.cpython-37.pyc
│
├───static
│ ├───base
│ │ styles.css
│ │
│ └───images
└───templates
home.html
navbar.html