le fichier css n'est pas pris en compte: "GET /static/css/style.css HTTP/1.1" 200 118
Bonjour,
Le rendu de la page html est fonctionnel mais le fichier css n'est pas pris en compte, le style ne s'applique pas.
Config:
- Django: 4.1.1
- python: 3.10.5
Hiérarchie du dossier: (J'ai crée le dossier graphic avec la commande python manage.py startapp graphic)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| * src
o testProject
----- ...
----- settings.py
----- urls.py
o graphic
------ admin.py
------ apps.py
------ models.py
------ tests.py
------ urls.py
------ views.py
------ static
------------ css
------------------ style.css
------------ js
------------------ script.js
------ templates
------------ graphic
------------------ index.html |
testProject/settings.py
Code:
1 2 3 4 5 6 7 8 9
| INSTALLED_APPS = [
...
'graphic',
]
STATIC_URL = 'static/'
STATICFILES_DIRS = [
BASE_DIR / "graphic/static",
] |
graphic/templates/graphic/index.html
Code:
1 2 3 4 5 6 7 8 9
| {% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
...
<link rel="stylesheet" href="{% static 'css/style.css' %}">
</head>
<body> <h1> Graphique </h1> </body>
</html> |