Django加载块为css [英] Django load block for css

查看:114
本文介绍了Django加载块为css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几页。对于每个页面,我需要加载唯一的css。
对于所有静态文件,我使用。在index.html的头上,我有:

  {%block css%} 

{% endblock%}

但是,例如,在contact.html中,我使用:

  {%extendsindex.html%} 
{%block css%}
< link rel =stylesheet href ={%staticcss / contact.css%}type =text / css/>
{%endblock%}

它的打印错误:
块标记无效:'static',expected'endblock'。如何解决?

解决方案

您需要使用 {%load static%} first。


I have a few pages. For every page I need load unique css. For all static files I use this. In the head of index.html I have:

{% block css  %}

{% endblock %}

But, for example, in contact.html I use:

{% extends "index.html" %}    
{% block css %}
    <link rel="stylesheet" href="{% static "css/contact.css" %}" type="text/css" />
    {% endblock %}

And its print error: Invalid block tag: 'static', expected 'endblock'. How to fix it?

解决方案

You need to use {% load static %} first.

这篇关于Django加载块为css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆