Wednesday, January 8, 2014

Re: Could not parse the remainder: '{{variabile}}' from '{{variabile}}'

When referencing a context variable within an if statement in a template, you don't need to use {{ var }}. Simply use: {% if variabile == "one" %}...{% elif variable == "two" %}...{% else %}...{% endif %}.

JDB


On Wed, Jan 8, 2014 at 9:33 AM, luca72 <lucaberto@libero.it> wrote:
hello the views file is like:

def test(request):
   testo = ["a","b"] 
   titolo = 'test'
   variabile = 'one'
   return render_to_response('vini.html',{'testo':testo,'titolo':titolo, 'testo':testo,'variabile':variabile,})

the template is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>{% block title %}{{titolo}}{% endblock %}</title>
</head>
<body>
<div id="titoli">
{% block titoli %} {% endblock %}
</div>
<div id="navcontainer">
 <ul id="navlist">
 {% if {{variabile}} == "one" %}
 <li id="active"><a href="/mostro_prima" id="current">History</a></li>
 <li><a href="/vini">Wines</a></li>
 <li><a href="#">Foods</a></li>
 {% elif {{variabile}} == "two" %}
 <li><a href="/mostro_prima">History</a></li>
 <li id="active"><a href="/vini" id="current">Wines</a></li>
 <li><a href="#">Foods</a></li>
 {% else %}
 <li><a href="/mostro_prima">History</a></li>
 <li><a href="/vini">Wines</a></li>
 <li id="active"><a href="#" id="current">Foods</a></li>
 {% endif %}
 </ul>
</div> 
<div id="main">
{% block main %}{% for n in testo %}<br/>{{n}}{% endfor %}
<br/><br/><br/>
Contact : <br/>
Tel: +xxxxxxxxxx </br>
Mobile: +xxxxxxxxx2<br/>
Email : <a href="xxxxxxxxxxxxxxxxxxxxxxx"> info@xxxxxxxxxxxxxxxxxm</a> 
{% endblock %}
</div>
<div id= "immagini">
</div>
</body>
</html>

Why i get the error how i can solve?

Thanks

Luca

--
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/f9137164-20c7-4ab1-bb43-4062c267b03a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Jonathan D. Baker
Developer
http://jonathandbaker.com

--
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/CAPMFOb5hYehpPsQcXoefukxz69wJRB-mXyd25eep-eZM7r%3DpwA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate