Monday, September 29, 2014

Re: templates: if and static tags incompatible?

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:fred@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.
On 9/29/14 12:41 PM, chansonsyiddish wrote:
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!


--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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.

No comments:

Post a Comment