Answer the question
In order to leave comments, you need to log in
How to include CSS (at least one file) in django?
I have already reviewed AND studied more than 10 articles. I read the documentation 3 times...
There is this:
As I understand it, this is a relative path in django to my static files.
Next, there is this:STATIC_URL = '/static/'
INSTALLED_APPS = [
'products',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>sitename</title>
<link rel="stylesheet" type="text/css" href="{% static 'main.css' %}">
</head>
<body>
{% include 'navbar.html' %}
{% block content %}
replace me
{% endblock %}
</body>
</html>
<link>
connect the static url again and it should find my main.CSS file. :c
base.html
Answer the question
In order to leave comments, you need to log in
There was a similar error
, it was necessary to write before connecting the link {% load static %}
plus that the static was in the application directory
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'main.css' %}">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question