Monday, January 30, 2017

Re: Unclear Debug Message (Bug?) When Invalid Url in Extended Template

Thanks. Please create a ticket with details:
https://code.djangoproject.com/newticket

On Saturday, January 28, 2017 at 11:10:40 PM UTC-5, Connor Boyle wrote:
Django 1.8 produces a reasonable error message (highlighting the problematic line in the relevant template file–though the formatting is a little odd), however Django 1.9 has the same problem as 1.10 and 1.11a.

On Saturday, January 28, 2017 at 10:04:42 PM UTC-6, Connor Boyle wrote:
Does not appear to be fixed in Django 1.11a1.

On Monday, January 23, 2017 at 7:31:22 PM UTC-6, Tim Graham wrote:
Could you check with Django 1.11a1? This might be fixed in https://code.djangoproject.com/ticket/27584.

On Saturday, January 21, 2017 at 6:02:27 PM UTC-5, Connor Boyle wrote:
I've noticed that when I extend a template that references an invalid url name, in debug mode, the error message doesn't highlight the erroneous line in the parent template, but rather shows a section of the child template.

For example if "base.html" is just:

{% block content %}{% endblock %}
<a href="{% url 'page_three' %}">Page Three</a>

And "page_one.html" is:

{% extends 'base.html' %}
{% block content %}<p>This is page one</p>{% endblock %}

when there is no url named "page_three", debug mode will show an error message entitled:

NoReverseMatch at /page_one/
Reverse for 'page_three' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

and show a few lines of page_one.html (instead of base.html, where the error originated). See attached screenshot for example.

Debug mode seems to do a fine job of highlighting the invalid line in the parent template for other errors, such as an {% if %} without an {% endif %} or an unrecognized tag (e.g. {% asdf %} ).

Is this a bug? Or at least a sorely missing feature? Am I crazy for thinking that this is not how this error should be displayed?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/30cd8231-2416-4fdf-8917-40026ba9a40f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment