在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
是什么意思?我在文档中找不到它。
[inclusion tag中使用的上下文变量名称
[result_list
的source code注释指出它“同时显示标题和数据列表”。
这是Changelist
:您的模型实例的列表。 Django使用它来处理过滤和分页任务。
Changelist
不是一般的东西;它是变量的名称,因此不在文档中。在此特定情况中,它是一个包含Changelist对象的变量,但这仅是因为它是传递给模板上下文的内容。