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

查看:132
本文介绍了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天全站免登陆