Mmm Donuts
Mmm Donuts

Reputation: 10283

Invalid Block Tag, Expected 'endblock'

I know this issue is all over stackoverflow, but this particular instance of it has me lost. The reason is, I get this error periodically - without changing the HTML file at all.

The issue seems to be here:

{% extends "base.html" %}
{% load static %}
{% load support_tags %}

{% block content_header %}
<h1>Header</h1>
{% endblock content_header %}

{% block new-main-area %}
        {% ticket_categories as categories %} {# Problem is here #}
            <option value="None">Select a Category</option>
        {% for cat in categories %}
            <option value="{{cat.slug}}">{{cat}}</option>
        {% endfor %}
{% endblock new-main-area %}

{% block extrascripts_bottom %}
{% endblock extrascripts_bottom %}

Thank you!

Upvotes: 1

Views: 4291

Answers (1)

falsetru
falsetru

Reputation: 368894

IMHO, the code is misusing with tag:

Replace following lines:

{% ticket_categories as categories %} <!-- Problem is here -->
    <option value="None">Select a Category</option>
{% for cat in categories %}
    <option value="{{cat.slug}}">{{cat}}</option>
{% endfor %}

with:

{% with ticket_categories as categories %} <!-- Problem is here -->
    <option value="None">Select a Category</option>
{% for cat in categories %}
    <option value="{{cat.slug}}">{{cat}}</option>
{% endfor %}
{% endwith %}

Or (with is not necessary at all):

<option value="None">Select a Category</option>
{% for cat in ticket_categories %}
    <option value="{{cat.slug}}">{{cat}}</option>
{% endfor %}

Upvotes: 3

Related Questions