Index: django/template/loader_tags.py
===================================================================
--- django/template/loader_tags.py	(revision 4451)
+++ django/template/loader_tags.py	(working copy)
@@ -129,7 +129,7 @@
         parser.__loaded_blocks.append(block_name)
     except AttributeError: # parser.__loaded_blocks isn't a list yet
         parser.__loaded_blocks = [block_name]
-    nodelist = parser.parse(('endblock',))
+    nodelist = parser.parse(('endblock','endblock %s' % block_name))
     parser.delete_first_token()
     return BlockNode(block_name, nodelist)
 
Index: docs/templates.txt
===================================================================
--- docs/templates.txt	(revision 4451)
+++ docs/templates.txt	(working copy)
@@ -253,6 +253,11 @@
       if you want to add to the contents of a parent block instead of
       completely overriding it.
 
+    * You can optionally name your ``{{ endblock }}`` tag with the same name
+      you gave the ``{{ block }}`` tag (for example, ``{{ endblock content }}``).
+      In larger templates this helps you see which ``{{ block }}`` tags are
+      being closed.
+
 Finally, note that you can't define multiple ``{% block %}`` tags with the same
 name in the same template. This limitation exists because a block tag works in
 "both" directions. That is, a block tag doesn't just provide a hole to fill --
Index: tests/regressiontests/templates/tests.py
===================================================================
--- tests/regressiontests/templates/tests.py	(revision 4451)
+++ tests/regressiontests/templates/tests.py	(working copy)
@@ -390,6 +390,20 @@
             'include03': ('{% include template_name %}', {'template_name': 'basic-syntax02', 'headline': 'Included'}, "Included"),
             'include04': ('a{% include "nonexistent" %}b', {}, "ab"),
 
+            ### NAMED ENDBLOCKS #######################################################
+
+            # Basic test
+            'namedendblocks01': ("1{% block first %}_{% block second %}2{% endblock second %}_{% endblock first %}3", {}, '1_2_3'),
+
+            # Unbalanced blocks
+            'namedendblocks02': ("1{% block first %}_{% block second %}2{% endblock first %}_{% endblock %}3", {}, template.TemplateSyntaxError),
+            'namedendblocks03': ("1{% block first %}_{% block second %}2{% endblock %}_{% endblock second %}3", {}, template.TemplateSyntaxError),
+            'namedendblocks04': ("1{% block first %}_{% block second %}2{% endblock second %}_{% endblock third %}3", {}, template.TemplateSyntaxError),
+
+            # Mixed named and unnamed endblocks
+            'namedendblocks05': ("1{% block first %}_{% block second %}2{% endblock %}_{% endblock first %}3", {}, '1_2_3'),
+            'namedendblocks06': ("1{% block first %}_{% block second %}2{% endblock second %}_{% endblock %}3", {}, '1_2_3'),
+
             ### INHERITANCE ###########################################################
 
             # Standard template with no inheritance
