Code

Ticket #17076: helpful_reverse.diff

File helpful_reverse.diff, 790 bytes (added by wilfred@…, 3 years ago)

Report the patterns tried by reverse()

Line 
1diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
2index 709a1fe..c8eb9df 100644
3--- a/django/core/urlresolvers.py
4+++ b/django/core/urlresolvers.py
5@@ -388,8 +388,11 @@ class RegexURLResolver(LocaleRegexProvider):
6             lookup_view_s = "%s.%s" % (m, n)
7         else:
8             lookup_view_s = lookup_view
9+
10+        patterns = [pattern for (possibility, pattern) in possibilities]
11         raise NoReverseMatch("Reverse for '%s' with arguments '%s' and keyword "
12-                "arguments '%s' not found." % (lookup_view_s, args, kwargs))
13+                "arguments '%s' not found. %d pattern(s) tried: %s" %
14+                             (lookup_view_s, args, kwargs, len(patterns), patterns))
15 
16 class LocaleRegexURLResolver(RegexURLResolver):
17     """