Opened 14 years ago
Closed 10 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 , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
Keywords: | url resolver added |
---|---|
Severity: | → Normal |
Type: | → Uncategorized |
comment:3 by , 14 years ago
Type: | Uncategorized → Cleanup/optimization |
---|
comment:4 by , 13 years ago
UI/UX: | unset |
---|
comment:6 by , 12 years ago
Component: | Core (Other) → Core (URLs) |
---|
comment:10 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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.
Change UI/UX from NULL to False.