【问题标题】:how to pass a template variable to a template tag in django?如何将模板变量传递给django中的模板标签?
【发布时间】:2015-06-22 03:32:59
【问题描述】:

我想将特定于页面呈现方式的模板变量传递给模板标记函数。我试过这个:

{{ lesson.description|program_refs:{{site_name}}|safe }}

我得到错误:

program_refs 需要 2 个参数,提供 1 个

【问题讨论】:

    标签: django django-templates django-template-filters


    【解决方案1】:

    像这样(变量名周围没有{{}}):

    {{ lesson.description|program_refs:site_name|safe }}
    

    【讨论】:

      猜你喜欢
      • 2012-09-27
      • 1970-01-01
      • 1970-01-01
      • 2020-04-24
      • 1970-01-01
      • 2011-03-04
      • 2021-02-15
      • 2019-04-03
      • 2013-03-06
      相关资源
      最近更新 更多