[Django] #29446: Include template context in error page when relevant

20 views
Skip to first unread message

Django

unread,
May 26, 2018, 5:58:09 AM5/26/18
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
-------------------------------------+-------------------------------------
Reporter: Shai | Owner: (none)
Berger |
Type: New | Status: new
feature |
Component: Error | Version: 2.0
reporting |
Severity: Normal | Keywords: template debug
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
When an error is encountered while rendering a template (in Debug mode),
Django helpfully displays the template source, followed by the usual
stack-trace with local variable values. It could be useful to also include
the template context at the point of the error, as these are often the
relevant "local variables".

While the context is actually often available as a local variable in one
of the function calls close to the bottom of the stack trace, it is not
obvious, and requires a somewhat tedious search (there are usually a
series of calls taking a `context` variable, most of them irrelevant).

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

Django

unread,
May 26, 2018, 9:18:12 PM5/26/18
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
---------------------------------+------------------------------------
Reporter: Shai Berger | Owner: (none)
Type: New feature | Status: new
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* stage: Unreviewed => Accepted


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

Django

unread,
Aug 9, 2018, 7:06:15 PM8/9/18
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
---------------------------------+------------------------------------
Reporter: Shai Berger | Owner: (none)
Type: New feature | Status: new
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Zach Bresser):

Shai,

Can you elaborate on what you mean? Are you suggesting we put the local
context variables in a special section instead of with the rest of the
local variables?

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

Django

unread,
Sep 14, 2019, 11:16:18 AM9/14/19
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
---------------------------------+------------------------------------
Reporter: Shai Berger | Owner: (none)
Type: New feature | Status: new
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by Min ho Kim):

Hi Shai Berger,
Could you give some more information about this feature request?
It would be nice to have some example of error page you would like to see.

If anyone else has any idea what the expected error page should look like,
please comment.

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

Django

unread,
Sep 14, 2019, 11:17:00 AM9/14/19
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
---------------------------------+------------------------------------
Reporter: Shai Berger | Owner: (none)
Type: New feature | Status: new
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
---------------------------------+------------------------------------
Changes (by Min ho Kim):

* cc: Min ho Kim (added)


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

Django

unread,
Feb 7, 2020, 4:10:29 AM2/7/20
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
---------------------------------+------------------------------------
Reporter: Shai Berger | Owner: (none)
Type: New feature | Status: new
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
---------------------------------+------------------------------------
Changes (by Vibhu Agarwal):

* cc: Vibhu Agarwal (added)


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

Django

unread,
Feb 7, 2020, 8:46:39 AM2/7/20
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
---------------------------------+-----------------------------------------
Reporter: Shai Berger | Owner: Vibhu Agarwal
Type: New feature | Status: assigned

Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
---------------------------------+-----------------------------------------
Changes (by Vibhu Agarwal):

* owner: (none) => Vibhu Agarwal
* status: new => assigned


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

Django

unread,
Mar 3, 2025, 5:00:56 PMMar 3
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
-------------------------------------+-------------------------------------
Reporter: Shai Berger | Owner: Bhupesh
| panwar
Type: New feature | Status: assigned
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Bhupesh panwar):

* owner: (none) => Bhupesh panwar
* status: new => assigned

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

Django

unread,
Mar 5, 2025, 1:07:09 AMMar 5
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
-------------------------------------+-------------------------------------
Reporter: Shai Berger | Owner: Bhupesh
| panwar
Type: New feature | Status: assigned
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Bhupesh panwar):

Hi, I am bhupesh Panwar, i recently reproduce this issue.I have
understand the issue very well. So i have a solution that can we create an
middleware.py file that logs template context when error happens
--
Ticket URL: <https://code.djangoproject.com/ticket/29446#comment:7>

Django

unread,
Mar 6, 2025, 2:51:10 PMMar 6
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
-------------------------------------+-------------------------------------
Reporter: Shai Berger | Owner: Bhupesh
| panwar
Type: New feature | Status: assigned
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Shai Berger):

First of all, I apologize for missing the calls for more details all these
years ago.
Somehow, I only saw them now.

Second,

Replying to [comment:7 Bhupesh panwar]:
> So i have a solution that can we create an middleware.py file that logs
template context when error happens

I think it would be more helpful to put the context in the error page with
all the other relevant info, but if you can pick the right context and put
it in the log, then IMO:
- It's a good first step towards putting it on the page
- It's already helpful in and of itself
--
Ticket URL: <https://code.djangoproject.com/ticket/29446#comment:8>

Django

unread,
Mar 6, 2025, 6:51:19 PMMar 6
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
-------------------------------------+-------------------------------------
Reporter: Shai Berger | Owner: Bhupesh
| panwar
Type: New feature | Status: assigned
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Antoliny):

* has_patch: 0 => 1

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

Django

unread,
Mar 6, 2025, 6:51:26 PMMar 6
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
-------------------------------------+-------------------------------------
Reporter: Shai Berger | Owner: Bhupesh
| panwar
Type: New feature | Status: assigned
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Antoliny):

[https://github.com/django/django/pull/19228 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/29446#comment:10>

Django

unread,
Mar 7, 2025, 11:38:36 AMMar 7
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
-------------------------------------+-------------------------------------
Reporter: Shai Berger | Owner: Bhupesh
| panwar
Type: New feature | Status: assigned
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Bhupesh panwar):

Replying to [comment:8 Shai Berger]:
Thank you reply, Shai, I have already raise an pr.there might be some
issue. i will keep you posted
--
Ticket URL: <https://code.djangoproject.com/ticket/29446#comment:11>

Django

unread,
Mar 8, 2025, 1:36:35 PMMar 8
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
-------------------------------------+-------------------------------------
Reporter: Shai Berger | Owner: Bhupesh
| panwar
Type: New feature | Status: assigned
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mike Edmunds):

* needs_better_patch: 0 => 1

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

Django

unread,
Mar 17, 2025, 6:12:38 PMMar 17
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
-------------------------------------+-------------------------------------
Reporter: Shai Berger | Owner: Bhupesh
| panwar
Type: New feature | Status: assigned
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Bhupesh panwar):

I created a new pull request because my previous one had some issues. Here
is the link: https://github.com/django/django/pull/19282 .

The issue is about retrieving the context (dictionary) from the user's
views.py. However, I couldn't find a way to retrieve the context from
views.py since the context variable name can vary depending on the user.

To illustrate this, I created a context.py file as an example. Could you
suggest how we can dynamically retrieve the context variable from
views.py?
--
Ticket URL: <https://code.djangoproject.com/ticket/29446#comment:13>

Django

unread,
Mar 18, 2025, 12:20:05 AMMar 18
to django-...@googlegroups.com
#29446: Include template context in error page when relevant
-------------------------------------+-------------------------------------
Reporter: Shai Berger | Owner: Bhupesh
| panwar
Type: New feature | Status: assigned
Component: Error reporting | Version: 2.0
Severity: Normal | Resolution:
Keywords: template debug | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mike Edmunds):

* has_patch: 1 => 0
* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/29446#comment:14>
Reply all
Reply to author
Forward
0 new messages