templates: if and static tags incompatible?

19 views
Skip to first unread message

chansonsyiddish

unread,
Sep 29, 2014, 12:43:21 PM9/29/14
to django...@googlegroups.com
Hello,

I've got a small problem:

here is the code in my template:

{% if p.fleches %}
<A HREF=#haut><img alt='haut-up' src="{% static "images/fleche-haut.jpg" %}" ></A>
{% endif %}

and the django development server tells me:

Django Version: 1.4.5
Exception Type: TemplateSyntaxError
Exception Value:
Invalid block tag: 'static', expected 'elif', 'else' or 'endif'

Is it a bug, or is it really impossible to put a static tag inside an if tag?

Thanks in advance!


Fred Stluka

unread,
Sep 29, 2014, 12:58:05 PM9/29/14
to django...@googlegroups.com
The problem is that static is not being recognized as a valid Django
tag.  Add this line to the top of the template file to define it.

{% load staticfiles %}

--Fred
Fred Stluka -- mailto:fr...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/54298BAD.6030606%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages