Opened 7 years ago

Last modified 7 years ago

#27956 closed Bug

In DEBUG interface, the section "error during template rendering" doesn't go inside an included template — at Initial Version

Reported by: Ling-Xiao Yang Owned by: nobody
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: ling-xiao.yang@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hello,

It seems that this problem only concerns Django 1.9 and 1.10. The problem has been fixed in the newest 1.11b1, but I am not sure if it has been backported to older versions.

How to verify:

  1. Start a new Django project, create two template html files, and make sure that template A uses `{% include %} tag to include the content of template B.
  2. Make an error inside template B. For example, in the screenshots below, I am passing in a model Question and using {{ Question.objects.all }} in template B (inner.html) to trigger an error.
  3. Complete a view function that renders template A, and add a url route for it. Try access this route with DEBUG=True.
  4. You will see the debug interface. In the section "Error during template rendering," you will see the error line being highlighted. The position and line number will be correct, but the error will be pointed to template A, while it should be pointed to template B where it actually happens.

Expected behavior:
I attached two screenshots, showing the expected behavior (using Django 1.11b1 and 1.8.11) and the actual behavior (using Django 1.10.6).

Note:
I discovered this problem while investigating the issue 902 of Django debug toolbar (on GitHub).
It is acceptable to invalidate this ticket if the fix has been ported to the branch Django 1.10.x, or it is mentioned elsewhere in the documentation.

Change History (3)

by Ling-Xiao Yang, 7 years ago

Attachment: 1-8-11.png added

Django 1.8.11 (correct)

by Ling-Xiao Yang, 7 years ago

Attachment: 1-10-6.png added

Django 1.10.6 (not correct)

by Ling-Xiao Yang, 7 years ago

Attachment: 1-11-b1.png added

Django 1.11b1 (correct)

Note: See TracTickets for help on using tickets.
Back to Top