Django 问题与扩展模板标签

标签 django django-templates

我正在尝试将上下文处理器中的变量放入标记模板“扩展”中:

{% 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/

相关文章:

javascript - 在 Javascript Django 中从 'param' 的 'views.py' 获取值

python - Django-Haystack with Solr 包含搜索

jquery - Django Jquery : based on selection, 显示更多选择选项

django - WSGIRequest错误使用django_model_comments

html - Django 模板上的 vscode html 自动套用格式

python - 'utf- 8' codec can' t 解码字节 - Python

python - 为每次调用外部 API 执行附加操作

django - 被 CORS 策略阻止 : No 'Access-Control-Allow-Origin' header is present on the requested resource

python - 模板渲染期间出现 TemplateSyntaxError

Django:通过 Django Admin 将用户添加到组