我正在尝试将上下文处理器中的变量放入标记模板“扩展”中:
{% extends {{ base_template|default:"mainpage.html" }} %}
但我有一个异常(exception):
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"
...
你能帮我解决这个问题吗?谢谢!
最佳答案
尝试删除 {{}}
--> {% extends base_template|default:"mainpage.html" %}
关于Django 问题与扩展模板标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2355805/