django INCLUDE tag only takes one argument (can't use WITH)
When I try to use the following include
{% include 'stream_doc.html' with doc=draft %}
in my HTML (draft
is an object in the context of a loop iteration), I get the error:
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 ta开发者_Python百科kes 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
Can anyone tell me what's going on? So far as I can tell I'm following the Django documentation. Is this something I can't do in app engine?
On Django 1.2 and below, I believe it is possible to circumvent this with
{% with draft as doc %}
{% include "stream_doc.html" %}
{% endwith %}
At least it works for my use case where I was passing a fixed value as in the documentation using
{% with "Jane" as person %}
Did you miss the bit in the docs you linked to which says "Changed in Django 1.3"? Your path indicates you're running Django 1.2. You should be looking at the 1.2 documentation.
精彩评论