[Django] #28050: TemplateSyntaxError should contain template name

41 views
Skip to first unread message

Django

unread,
Apr 7, 2017, 7:52:48 AM4/7/17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr | Owner: nobody
Dlouhý |
Type: New | Status: new
feature |
Component: Template | Version: 1.11
system | Keywords: TemplateSyntaxError
Severity: Normal | template
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
If there is an error in template, Django doesn't report the template name.
It could be quite uneasy to find the buggy template in such case.

e.g.: I have got following error:
{{{
File "/home/petr/soubory/programovani/Auto-
mat/DPNK/dpnk/env/lib/python3.5/site-packages/django/template/base.py",
line 509, in parse
self.invalid_block_tag(token, command, parse_until)
File "/home/petr/soubory/programovani/Auto-
mat/DPNK/dpnk/env/lib/python3.5/site-packages/django/template/base.py",
line 565, in invalid_block_tag
get_text_list(["'%s'" % p for p in parse_until], 'or'),
django.template.exceptions.TemplateSyntaxError: Invalid block tag on line
127: 'endblock', expected 'empty' or 'endthumbnail'. Did you forget to
register or load this tag?

}}}
It contains even line number, but I have no idea in which file.

I think, it is not that difficult to include template name in the bug
report. In my case I tried to debug the error call. In
`django.template.base`, the `invalidb_block_tag` is called from `parse()`
where the template name can be obtained from `self.origin.template_name`.

--
Ticket URL: <https://code.djangoproject.com/ticket/28050>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 7, 2017, 8:39:21 AM4/7/17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by kapil garg):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:1>

Django

unread,
Apr 7, 2017, 9:54:27 AM4/7/17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: kapil
| garg
Type: New feature | Status: assigned

Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by kapil garg):

* status: new => assigned
* owner: nobody => kapil garg


--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:2>

Django

unread,
Apr 9, 2017, 9:35:05 AM4/9/17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: kapil
| garg
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by kapil garg):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:3>

Django

unread,
May 27, 2017, 12:56:10 PM5/27/17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: kapil
| garg
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1


Comment:

I'm not particularly pleased with the current patch which causes the
template name to be displayed redundantly several times in the debug view.
Hopefully we could avoid that.

--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:4>

Django

unread,
Aug 17, 2017, 2:30:44 PM8/17/17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Roger
| Masse

Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Roger Masse):

* owner: kapil garg => Roger Masse


Comment:

My plan is to improve the patch as described in the pull request with the
suggestion by timgraham:

''There might be a possibility for the debug view to modify
TemplateDoesNotExist's message so the redundant template names aren't
added. In any case, a test is required.''

--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:5>

Django

unread,
Aug 17, 2017, 7:05:16 PM8/17/17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Roger
| Masse
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Roger Masse):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:6>

Django

unread,
Aug 17, 2017, 7:06:34 PM8/17/17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Roger
| Masse
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Roger Masse):

* has_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:7>

Django

unread,
Aug 17, 2017, 7:07:04 PM8/17/17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Roger
| Masse
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Roger Masse):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:8>

Django

unread,
Aug 17, 2017, 7:21:34 PM8/17/17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Roger
| Masse
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Roger Masse):

* cc: Roger Masse (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:9>

Django

unread,
Oct 11, 2017, 11:19:57 AM10/11/17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Roger
| Masse
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

#28698 is a duplicate with an alternate approach.

--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:10>

Django

unread,
Nov 28, 2017, 6:05:32 PM11/28/17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Roger
| Masse
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Martin):

* has_patch: 1 => 0


Comment:

The original pull request was closed by the author, and there's another
branch open that doesn't have a pull request yet (and I think still needs
some rebasing / squashing?)

If anyone thinks there's a clean patch available for this please post a
fresh link to it.

--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:11>

Django

unread,
Nov 28, 2017, 7:14:27 PM11/28/17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Roger
| Masse
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1

* has_patch: 0 => 1


Comment:

There's [https://github.com/django/django/pull/8974 PR 8974] but I'm still
not convinced it's ideal.

--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:12>

Django

unread,
Jan 28, 2018, 2:39:35 AM1/28/18
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Roger
| Masse
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Himanshu Chauhan):

I think that in case of Template Syntax Error it is very unhelpful to show
the python traceback because that will be usually same for all the errors
of this kind and as mentioned in the ticket does not show the template
file path where the error has been encountered. So my solution is to catch
the template syntax error exception and instead of going for default
python exception handling mechanism, we actually display the template
path, template line number and the exception message which I believe will
be more useful than the default python traceback in debugging template
errors.

I would like to work on this and want to know your views about my
approach.

--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:13>

Django

unread,
Jun 3, 2023, 5:41:25 AM6/3/23
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Tim
| McCurrach

Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim McCurrach):

* owner: Roger Masse => Tim McCurrach


--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:14>

Django

unread,
Jun 3, 2023, 12:37:44 PM6/3/23
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Tim
| McCurrach
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_tests: 0 => 1


Comment:

[https://github.com/django/django/pull/16937 New PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:15>

Django

unread,
Jul 21, 2024, 9:04:55 PM7/21/24
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Tim
| McCurrach
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Emmanuel Katchy):

Replying to [comment:14 Tim McCurrach]:
Hi Tim, are you still free to work on this?

It appears the PR only needs tests to get accepted.
--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:16>

Django

unread,
Jul 22, 2024, 6:04:28 AM7/22/24
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Tim
| McCurrach
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Emmanuel Katchy):

* cc: Emmanuel Katchy (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:17>

Django

unread,
Mar 18, 2025, 1:33:05 PMMar 18
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Farhan
| Ali
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Farhan Ali):

* owner: Tim McCurrach => Farhan Ali

--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:18>

Django

unread,
Mar 20, 2025, 11:50:20 PMMar 20
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Farhan
| Ali
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Farhan Ali):

* cc: Farhan Ali (added)
* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:19>

Django

unread,
Apr 5, 2025, 10:30:39 AMApr 5
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Farhan
| Ali
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Farhan Ali):

* needs_tests: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:20>

Django

unread,
Apr 15, 2025, 7:18:17 AMApr 15
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Farhan
| Ali
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Accepted
template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_tests: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:21>

Django

unread,
Apr 16, 2025, 3:46:23 AMApr 16
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Farhan
| Ali
Type: New feature | Status: assigned
Component: Template system | Version: 1.11
Severity: Normal | Resolution:
Keywords: TemplateSyntaxError | Triage Stage: Ready for
template | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:22>

Django

unread,
Apr 17, 2025, 2:57:03 AMApr 17
to django-...@googlegroups.com
#28050: TemplateSyntaxError should contain template name
-------------------------------------+-------------------------------------
Reporter: Petr Dlouhý | Owner: Farhan
| Ali
Type: New feature | Status: closed
Component: Template system | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: TemplateSyntaxError | Triage Stage: Ready for
template | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"4a293eff6fb10a04de7c65ed705ca3c6a362a587" 4a293ef]:
{{{#!CommitTicketReference repository=""
revision="4a293eff6fb10a04de7c65ed705ca3c6a362a587"
Fixed #28050 -- Added template name to TemplateSyntaxError.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28050#comment:23>
Reply all
Reply to author
Forward
0 new messages