Django Duplicate Blocks

ID

python.django_duplicate_blocks

Severity

low

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Reliability

Language

Python

Tags

framework-django, reliability, template

Description

Reports two {% block X %} tags with the same name in the same template. Django raises TemplateSyntaxError: 'block' tag with name 'X' appears more than once — but only when the template is actually rendered, so the bug typically slips through review and bites in production.

{% block content %} ... {% endblock %}
{% block content %} ... {% endblock %}    <!-- FLAW -->

Rationale

The duplicate is a render-time error, not a parse-time one — so the template ships, passes any "the file exists" smoke test, and only crashes once the real view tries to render it.

Remediation

Rename one of the duplicate blocks, or merge them into one.

References