Saturday, August 6, 2011

if condition in template not working

The if condition in my html template is not working, only else is
executing.

view function is
def test(request):
lists=Book.objects.all()
return render_to_response('test.html',{'book':lists})


template file:test.html

<html>
<body>
{% if lists %}
{% for a in lists %}
<p>There are {{book|length}} books.</p>
<ul><li>a.title</li></ul>
{% endfor %}
{%else%}
<p>no results</p>
{%endif%}
</body>
</html>


when i go to the url from the browser i got only "no results"
This is the case in other view functions also.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate