Defining “global variable” in Django templates

后端 未结 5 914
情书的邮戳
情书的邮戳 2020-12-16 04:52

I\'m doing something like:

{% extends \'base.html\' %}
{% url myapp.views.dashboard object as object_url %}
{% block sidebar %}
... {{ object_url }} ...
{% e         


        
5条回答
  •  醉酒成梦
    2020-12-16 05:46

    In every inherited template any code outside blocks redefinitions is not executed. So in your example you have to call {% url %} tag inside each block or use context processor for setting "global" variable.

提交回复
热议问题