Django templates syntax error

前端 未结 2 1054
忘掉有多难
忘掉有多难 2021-01-19 05:59

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

{% ifequal chat_profile 1 %}         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-19 06:15

    True, you must use extends as the first tag, but you can also pass it a variable instead of a fixed string:

    {% extends base %}
    

    Then you can include a context variable named base with the name of the template to inherit from, e.g.:

        return render_to_response('my_template.html',
                              { 'base': 'chatprofile/chat_profile1.html' })
    

提交回复
热议问题