Django templates syntax error

穿精又带淫゛_ 提交于 2019-12-01 18:38:27

The documentation states:

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

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

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' })
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!