【问题标题】:Django: in template tag what does cl mean?Django:在模板标签中,cl 是什么意思?
【发布时间】:2016-04-28 18:28:08
【问题描述】:

在 django 管理更改列表模板中有一个块:

  {% block result_list %}
      {% if action_form and actions_on_top and cl.show_admin_actions %}{% admin_actions %}{% endif %}
      {% result_list cl %}
      {% if action_form and actions_on_bottom and cl.show_admin_actions %}{% admin_actions %}{% endif %}
  {% endblock %}

我想知道{% result_list cl %} 是做什么的,即cl 是什么意思?我在文档中找不到它。

【问题讨论】:

    标签: django django-templates templatetags


    【解决方案1】:

    它是在inclusion tag 中使用的上下文变量名称

    result_listsource code 评论指出它“同时显示标题和数据列表”。

    【讨论】:

    • inclusion 标签链接失效,这里是当前页面的链接:inclusion tag
    【解决方案2】:

    这是一个Changelist:您的模型实例列表。 Django 使用它来处理过滤和分页任务。

    【讨论】:

      【解决方案3】:

      cl 不是一般的东西;它是一个变量的名称,所以它不会出现在文档中。在这种特殊情况中,它是一个保存 Changelist 对象的变量,但这仅仅是因为这是传递给模板上下文的内容。

      【讨论】:

        猜你喜欢
        • 2010-09-29
        • 2017-07-29
        • 2015-08-28
        • 2018-08-22
        • 2016-01-31
        • 2022-09-23
        • 1970-01-01
        • 2014-01-08
        相关资源
        最近更新 更多