Django problem with template tag extension

I am trying to put a variable from the context processor into the 'extends' tag template:

{% extends {{ base_template|default:"mainpage.html" }} %}

but I got an exception:

Exception Value: 'extends' takes one argument

my context_processors.py:

from django.conf import settings

def search(request):

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

and settings.py:

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

Can you help me? Thank!

+3
source share
1 answer

Try to delete {{}}{% extends base_template|default:"mainpage.html" %}

+11
source

Source: https://habr.com/ru/post/1734872/


All Articles