diff options
| author | ekinertac <ekinertac@gmail.com> | 2024-10-06 15:29:35 +0300 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-10-10 12:21:02 +0200 |
| commit | 68cee15a8fd65bd6ee2329d80331f87cadd97ff5 (patch) | |
| tree | 7c2280cb78d4cbe61e8426f95c2f5116d4aee724 /django | |
| parent | e970bb7ca71c00594b42a024a15a8ac007cc2c7a (diff) | |
Fixed #35789 -- Improved the error message raised when the tag must be first in the template.
Diffstat (limited to 'django')
| -rw-r--r-- | django/template/base.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/template/base.py b/django/template/base.py index ee2e145c04..b974495c9c 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -533,9 +533,13 @@ class Parser: def extend_nodelist(self, nodelist, node, token): # Check that non-text nodes don't appear before an extends tag. if node.must_be_first and nodelist.contains_nontext: + if self.origin.template_name: + origin = repr(self.origin.template_name) + else: + origin = "the template" raise self.error( token, - "%r must be the first tag in the template." % node, + "{%% %s %%} must be the first tag in %s." % (token.contents, origin), ) if not isinstance(node, TextNode): nodelist.contains_nontext = True |
