Opened 13 years ago
Closed 11 years ago
#17076 closed Cleanup/optimization (fixed)
Report the number of patterns tried when reversing
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (URLs) | Version: | 1.3 |
Severity: | Normal | Keywords: | reverse |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Relevant django-dev discussion: http://groups.google.com/group/django-developers/browse_thread/thread/d3bcc13fff8d7320
It would be great to know which patterns were tested when NoReverseMatch
is thrown. This would help distinguish between "I've typed the URL name incorrectly" and "I've missed a keyword argument for this URL".
Patch attached, I would welcome feedback.
The current patch produces the following exception if the URL name is wrong:
NoReverseMatch: Reverse for 'incorrect_url_name' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
And the following exception if a keyword argument is missing:
NoReverseMatch: Reverse for 'needs_exactly_one_kwargs' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['user/(?P<user_id>\\d+)/update/$']
Attachments (2)
Change History (7)
by , 13 years ago
Attachment: | helpful_reverse.diff added |
---|
comment:1 by , 13 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
I think your list comprehension statement needs some work based on this:
https://github.com/django/django/blob/master/django/core/urlresolvers.py#L361
comment:2 by , 13 years ago
Cripes, I must have tested on an older version. Sorry about that. Here's an updated patch.
by , 13 years ago
Attachment: | helpful_reverse_1_4.diff added |
---|
updating patch to work correctly against trunk
comment:3 by , 12 years ago
Component: | Core (Other) → Core (URLs) |
---|
comment:4 by , 11 years ago
I've opened a pull request against trunk on GitHub, with a unit test. See https://github.com/django/django/pull/1266 .
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Report the patterns tried by reverse()