Bonjour,
Je suis en train de faire un site web avec django (je suis débutant), le fichier css n'est pas pris en compte pourriez-vous m'aider svp
Voici l'arborescence des différents fichiers
Voici ce que j'ai modifié dans le fichier setting
Voici une des pages utilisant le fichier css :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.2/howto/static-files/ STATIC_URL = '/static/' STATICFILES_DIRS = [ BASE_DIR / 'static', ]
Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 {% extends 'template_base.html' %} {% load static %} {% block titre %}Contact{% endblock %} {% block stylesheets %} <link rel="stylesheet" type="text/css" href="{% static 'style.css' %}"> {% endblock %} {% block contenu %} <h1>Contact</h1> {% endblock %}
Voici le fichier template :
Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 <!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>{% block titre %}{% endblock %}</title> {% block stylesheets %}{% endblock %} </head> <body> <h1>Website#1</h1> <ul style="list-style: none"> <li style="display: inline-block; padding: 10px 20px;"><a href="{% url 'home' %}">Home</a></li> <li style="display: inline-block; padding: 10px 20px;"><a href="{% url 'mechanic3d' %}">Mechanic3d</a></li> <li style="display: inline-block; padding: 10px 20px;"><a href="{% url 'sculpt3d' %}">Sculpt3d</a></li> <li style="display: inline-block; padding: 10px 20px;"><a href="{% url 'computing' %}">Computing</a></li> <li style="display: inline-block; padding: 10px 20px;"><a href="{% url 'contact' %}">Contact</a></li> </ul> {% block contenu %} {% endblock %} </body> </html>
merci
Partager