Opened 13 years ago

Closed 9 years ago

#14343 closed Cleanup/optimization (fixed)

NoReverseMatch error message is unclear, view does exist

Reported by: Diederik van der Boor Owned by: nobody
Component: Core (URLs) Version: 1.2
Severity: Normal Keywords: url, resolver
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As Django newcomer, the NoReverseMatch error appears confusing to me.
It took me about 1 hour to figure out my problem because the error message was unclear.
This might not be technically a bug but I believe this is a "user experience" bug.


This is the error message:

Caught NoReverseMatch while rendering: Reverse for 'webgtd-contexts-index' with arguments '()' and keyword arguments '{}' not found.

The line in error was:

<a accesskey="c" href="{% url webgtd-contexts-index %}">

The URLConf has the following entry:

    url(r'^contexts/(?P<id>\d*)$', 'todo.by_context', name='webgtd-contexts-index'),

The todo view looked like like:

def by_context(request, id=0):
    return index(request)

In my reasoning this parameter would be optional, but I was wrong.
The function signature looked fine to me, which made the error message confusing.

I've rewritten the regex now as: '^contexts/(?P<id>\d+)?$'.


Could you please improve the error message, so that it either:

  • ...mentions the view function does not exist at all.
  • ...mentions the view function does exist, but requires more parameters
  • ...mentions the URLconf regex pattern requires more parameters

Change History (10)

comment:1 by Daniel F Moisset, 13 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Graham King, 13 years ago

Keywords: url resolver added
Severity: Normal
Type: Uncategorized

comment:3 by Julien Phalip, 13 years ago

Type: UncategorizedCleanup/optimization

comment:4 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 by Aymeric Augustin, 11 years ago

Component: Core (Other)Core (URLs)

comment:7 by Aymeric Augustin, 11 years ago

#19091 was a duplicate.

comment:8 by Aymeric Augustin, 11 years ago

#18373 is related.

comment:9 by Wilfred, 11 years ago

#17076 is related.

comment:10 by Bas Peschier, 9 years ago

Resolution: fixed
Status: newclosed

I am going to close this on the basis that the NoReverseMatch now contains the tried pattern(s):

django.core.urlresolvers.NoReverseMatch: Reverse for 'webgtd-contexts-index' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['contexts/(?P<id>\\d*)$']

This means the NoReverseMatch is no longer a complete dead end: it now provides a bit of information where to look. Since there are a lot of reasons the pattern could not match (especially now we support lookarounds), it is going to be very difficult to provide more information.

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