Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Invalid Block Tag: 'endfor'

I wrote these for loop, but I got the Error : Django Invalid Block Tag: 'endfor'

{ % for post in post_list %}
    <div>
    {{ post.title }}
    {{ post.created_at }}
    {{ post.photo }}
    {{ post.content }}
    </div>
{% endfor %}
like image 460
Shuan Wu Avatar asked Feb 14 '16 08:02

Shuan Wu


1 Answers

You're getting that error because there is a space between { and % where the for tag begins.

Change this - { % to look like this - {%, i.e. remove the space between { and %:

{% for post in post_list %}
    ...
{% endfor %}
like image 62
xyres Avatar answered Oct 27 '22 06:10

xyres