1

So I am trying to create navigation bar to my django template but I can't make any css adjustments. Django doesn't throw any error messages...

{% load static %}

<head>
    <link rel='stylesheet' type='varaustiedot/styles.css' href="{% static 'style.css' %}"/>
    <title>Varaus</title> <! Varaus = Reserve>
</head>

<body>
    <div class="topnav">
        <!>
        
        <!a class="active" href="home"><!/a>
        <a href="register">Varaa</a>
        <a href="#">Yhteystiedot</a>
        <a href="#">Tietoa meistä</a>
    </div>

</body>

Here is my css file


html,
body{
    font-size: 15px;
    background-color: #1f2029;
}
.osoite{
    margin: auto;
    width: 50%;
    text-align: center;
}
.centered-form {
    text-align: center;
 }
.topnav{
    text-align: right;
    margin-top: 20px;
    margin-bottom: 40px;
    padding: 20px;
    background-color: black;
}

I tried to google the answer and I even asked chatbotGPT. So far I haven't found any issues. I have changed class names and all the names I could think of.

I had

?{% now "U" %}

when i did that link at first. But it didn't seem to do anything and every time I refreshed the site and had done some changes to css code (I checked with control + u) it had been updated...

I am not sure if there is some sort of typo or something like that but usual

?{% now "U" %}

fix didn't seem to work for me. I can try it again if it makes any difference but so far nothing.

2
  • Why do you have type='varaustiedot/styles.css' in your stylesheet tag? Probably should remove this attribute Commented Dec 14, 2022 at 14:02
  • I don't know about django, but remove type='varaustiedot/styles.css' and check if browser could find the css file, if still not working, please share your outputted page source Commented Dec 14, 2022 at 14:14

2 Answers 2

1

loading css is a headache in django ...it saves to cache you need to empty cache and collectstatic

what i am using is

1- make a css.html with <style> your_css </style> tag and put the css in it

2- in the page i need the css i use the {%include "css.html"%} to load the css

you edit directly... no cache no collectstatic..nothing

Sign up to request clarification or add additional context in comments.

Comments

0

My code worked when thanks to commentors I deleted the type from my stylesheet tag.

 <link rel='stylesheet' href="{% static 'style.css' %}?{% now 'U' %}"/>

It works now

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.