Django 模板语法错误 [英] Django templates syntax error

查看:29
本文介绍了Django 模板语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面代码的语法有没有问题,有错误为无效的块标签:'else'

Is there any problem with the syntax in the following code, there is a error as Invalid block tag: 'else'

{% ifequal chat_profile 1 %}
    {% extends "chatprofile/chat_profile1.html" %}
{% else %}
    {% extends "chatprofile/chat_profile.html" %}
{% endifequal %}

推荐答案

文档指出:

如果您在模板中使用 {% extends %},它必须是该模板中的第一个模板标记.否则模板继承将不起作用.

If you use {% extends %} in a template, it must be the first template tag in that template. Template inheritance won't work, otherwise.

因此请考虑使用可以使用 {% include %} 代替的设计.

So consider using a design where you can use {% include %} instead.

这篇关于Django 模板语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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