Monday, January 23, 2017

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

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/daa134e4-604a-450a-897e-d43cb90b4fb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment