Skip to content

duplicate-block-name

Added in 0.2.11 · Related issues · View source

What it does

Checks for multiple {% block %} tags that share the same name within a single template.

Why is this bad?

Django requires {% block %} names to be unique within a template. A block both provides a hole for a child template to fill and defines the default content for that hole, so two blocks with the same name are ambiguous. Django raises a TemplateSyntaxError when the template is parsed, so a duplicate name breaks the template at runtime.

Example

{% block title %}Title 1{% endblock %}
{% block title %}Title 2{% endblock %}

Use instead:

{% block title %}Title 1{% endblock %}
{% block subtitle %}Title 2{% endblock %}

References