django INCLUDE标记只接受一个参数(不能使用WITH)

Han*_*ank 1 django google-app-engine

当我尝试使用以下包括

{% include 'stream_doc.html' with doc=draft %}
Run Code Online (Sandbox Code Playgroud)

在我的HTML(draft是循环迭代的上下文中的对象),我得到错误:

  File "C:\Program Files (x86)\Google\google_appengine\lib\django_1_2\django\template\loader_tags.py", line 210, in do_include
raise TemplateSyntaxError("%r tag takes one argument: the name of the template to be included" % bits[0])
TemplateSyntaxError: u'include' tag takes one argument: the name of the template to be included
Run Code Online (Sandbox Code Playgroud)

谁能告诉我发生了什么事?据我所知,我正在关注Django 文档.这是我在app引擎中无法做到的事情吗?

nim*_*smi 6

在Django 1.2及以下版本中,我相信可以用它来规避这个问题

{% with draft as doc %}
{% include "stream_doc.html" %}
{% endwith %}
Run Code Online (Sandbox Code Playgroud)

至少它适用于我使用的文档中传递固定值的用例

{% with "Jane" as person %}
Run Code Online (Sandbox Code Playgroud)