django-templatessyntax-error

Why does the typo {$ block content %} cause an error?


I'm getting this error --> Invalid block tag on: 'endblock'. Did you forget to register or load this tag?

I made sure to indent and putting space correctly and yes I do have latest version of pycharm.

What would make it work correctly?

{% extends 'mc_application_folder/base.html' %}

{$ block content %}

<p>Topics: {{ topic }}</p>

<p>Entries:</p>
<ul>
{% for entry in entries %}
    <li>
        <p>{{ entry.date_added|date:'M d, Y H:i' }}</p>
        <p>{{ entry.text|linebreaks }}</p>
    </li>
{% empty %}
    <li>There are no entries for this topic yet.</li>
{% endfor %}
</ul>

{% endblock content %}

Solution

  • I think the error is just because of the closing tag {%endblock content%}. We don't need to specify content there but simply use {% endblock %}.

    Full code here;

    {% extends 'mc_application_folder/base.html' %}
    
    {% block content %}
    
    <p>Topics: {{ topic }}</p>
    
    <p>Entries:</p>
    <ul>
    {% for entry in entries %}
        <li>
            <p>{{ entry.date_added|date:'M d, Y H:i' }}</p>
            <p>{{ entry.text|linebreaks }}</p>
        </li>
    {% empty %}
        <li>There are no entries for this topic yet.</li>
    {% endfor %}
    </ul>
    
    {% endblock %}