django template: Is extended template able to change css in parent page?

后端 未结 3 845
鱼传尺愫
鱼传尺愫 2021-02-04 18:51

I have two django template pages, one of them is \"base.html\", with basic html tags setup as a base template. Now I have a page \"child.html\" that extends it, with something l

3条回答
  •  囚心锁ツ
    2021-02-04 19:21

    To do this add a block in base.html in the head that allow you to inset another css AFTER the one in base.html

    
    
        .... other head tags ....
    
        
        {% block extra_css %}{% endblock %}
    
    

    This allows you to override css tags in template_conf.css by adding in another tag in child.html

    {% block extra_css %}
    
    {% endblock %}
    

    This allows you to override the partd of base.html that needs to change, while still being able to tweak the parts of the page in child.html that are required.

提交回复
热议问题