Any way to make {% extends '...' %} conditional? - Django
The other answers require you to pass an additional context variable. But as long as you can access the request object, there is no need:
{% extends request.is_ajax|yesno:"app/base_ajax.html,app/base.html" %}
I found this to be much more convenient.
Use a variable.
{% extends base_template %}
and in your view, set it to "base.html" in your view, or a new "ajax.html" file which just provides the block and nothing else.
{% extends override_base|default:'base.html' %}
P.s. I know this is an old question, but I found it when searching for an answer. Maybe it'll help someone else with the same problem.