简体   繁体   中英

Why doesn't href from HTML to CSS work correctly with Django?

I have the next problem:

Im ceating a basic django webpage using HTML and CSS. The issue is that when I try to make the href from the HTML file to the CSS one:

<link rel="stylesheet" type="text/css" href="modelado.css">

It doesn't work correctly. my HTML file called "inicio.html" and "modelado.css" are in the same folder, but once I make the href, the console says this:

Not Found: /inicio/modelado.css

I think that the console is trying to find a folder called "inicio", but that's impossible since inicio is the HTML file from where I am running the program. What I want to know is if there is another way to write the direction, because that directory doesn't exist. I also think that this is a django related problem, because when I only use HTML, that line of code actually works when the files are in the same folder.

Thanks!

CSS is not a dynamic file (it is static) so by using

{% load static %}
<link rel="stylesheet" href="{% static 'yourstyle.css' %}">

you can load static files (like css).

More info here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM