alvinzoo
alvinzoo

Reputation: 513

Django template: Invalid block tag: 'endif', expected 'empty' or 'endfor'

I am getting an error saying my template is not correct.

The error goes like: Invalid block tag: 'endif', expected 'empty' or 'endfor'

My code is here, the bug is on the last line. Which part is not correct?

{% if entries %}
{% for entry in entries %}
<section class="no-padding" id="portfolio">
    <div class="container-fluid">
        (% if entry.scammer_name %}
        <div class="row no-gutter result-wrapper control-group">
            <div class="col-lg-3 result-label">
                <label class="control-group result-padding">
                    suspect's name:
                </label>
            </div>    
            <div class="col-lg-9 result">
                <label class="control-group result-padding light-font">
                    {{ entry.scammer_name }}
                </label>
            </div>    

        </div>
        {% endif %}
    </div>
</section>
{% endfor %}
{% endif %}

Upvotes: 0

Views: 3314

Answers (2)

kangfend
kangfend

Reputation: 365

Add {% endfor %}{% endif %} to the last line of code.

Upvotes: 1

Mikeec3
Mikeec3

Reputation: 649

For loops require endfor tags

{% if mike %}
  {% if jake %}
    {% for x in squid %}
      {{ x.do_stuff }}
    {% endfor %}
  {% endif %}{# closes jake tag #}
{% endif %}{# closes mike tag #}

Upvotes: 0

Related Questions