我正在尝试将变量从上下文处理器放入标记模板'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"
...
你可以帮帮我吗?谢谢!
答案 0 :(得分:11)
尝试删除{{}}
- > {% extends base_template|default:"mainpage.html" %}
答案 1 :(得分:0)
{% extands %}
{% extands 'anotherpage.html'%}
like
{% extands %}
{% extands 'base.html'%}