用于css的Django加载块 [英] Django load block for css

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

问题描述

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

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 %}

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

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 %}

并且其打印错误:
无效的代码段:'static',expected'endblock'。如何解决?

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

推荐答案

您需要使用 {%load static%} 第一。

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

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