Any way to make {% extends '…' %} conditional? - Django

前端 未结 4 751
长发绾君心
长发绾君心 2020-11-27 04:21

I would like to share a template between AJAX and regualr HTTP calls, the only difference is that one template needs to be served with the base.html html, the other one with

4条回答
  •  -上瘾入骨i
    2020-11-27 04:42

    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.

提交回复
热议问题