Grebalb
Grebalb

Reputation: 113

How do I switch css file between templates?

Im trying to switch css files between my html templates.

This is in my base_generic html file:

{% block ccs %}
        <link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}">
 {% endblock %}

And this is how I'm trying to overwrite it in my template:

{% extends "base_generic.html" %}


{% block css %}
<link rel="stylesheet" type="text/css" href="{% static 'css/detail.css' %}">
{% endblock %}

I want it to load the detail.css file in my template but it loads the base.css on every page. I've tried different browsers (one with a completely empty cache) so it isn't a browser problem. What am I missing?

Upvotes: 0

Views: 69

Answers (1)

shekhar
shekhar

Reputation: 161

{% block ccs %}
    <link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}">
{% endblock %}

You are using this in you base html and in another html if you want to override it then correct your CCS to css

{% block css %}  **in this line change css to ccs or in your base html change ccs to css **
   <link rel="stylesheet" type="text/css" href="{% static 'css/detail.css' %}">
{% endblock %}

I hope this will work for you.

Upvotes: 3

Related Questions