Django使用extends模板标签出现问题

3
我正在尝试将上下文处理器中的变量放入标签模板“extends”中:
{% extends {{ base_template|default:"mainpage.html" }} %}

但是我遇到了一个异常:

Exception Value: 'extends' takes one argument

我的context_processors.py文件:

from django.conf import settings

def search(request):

"""Adds settings for test"""
return {
        'base_template' : settings.BASE_TEMPLATE,
}

还有settings.py:

...
BASE_TEMPLATE = "test/base.html"
...

你能帮我翻译一下吗?谢谢!

2个回答

11

尝试去除 {{}} --> {% extends base_template|default:"mainpage.html" %}


0

{% extands %}
{% extands 'anotherpage.html'%}
like
{% extands %}
{% extands 'base.html'%}


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接