Karis Morgan
Karis Morgan

Reputation: 1

TemplateSyntaxError in Django

I am following the django app tutorial and I get this error...

Invalid block tag on line 5: 'endfor', expected 'elif', 'else' or 'endif'. Did you forget to register or load this tag?

Request Method: GET Request URL: http://127.0.0.1:8000/polls/ Django Version: 1.10.1 Exception Type: TemplateSyntaxError Exception Value:
Invalid block tag on line 5: 'endfor', expected 'elif', 'else' or 'endif'. Did you forget to register or load this tag? Exception Location: C:\Python34\Orange\lib\site-packages\django\template\base.py in invalid_block_tag, line 568 Python Executable: C:\Python34\Orange\python.exe Python Version: 3.4.4 Python Path:
['C:\xampp\htdocs\django\mysite', 'C:\WINDOWS\SYSTEM32\python34.zip', 'C:\Python34\Orange\DLLs', 'C:\Python34\Orange\lib', 'C:\Python34\Orange', 'C:\Python34\Orange\lib\site-packages'] Server time: Sat, 29 Oct 2016 21:30:59 +0300

My index.html looks like this...

{% if latest_question_list %}
<ul>
    {% for question in latest_question_list % }
    <li><a href="/polls/{{ question.id }}/">{{question.question_text}}</a></li>
    {% endfor %}
</ul>
{% else %}
<p>No polls available</p>{% endif %}

What am I doing wrong? Appreciated.

Upvotes: 0

Views: 4358

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599600

You have a space between the % and the closing } on the for tag, so Django doesn't recognise it. Remove that.

Upvotes: 1

Related Questions