summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2009-09-10 11:08:16 +0000
committerLuke Plant <L.Plant.98@cantab.net>2009-09-10 11:08:16 +0000
commit4b82421a8503788b8a9ea517525ca3fc44de2e55 (patch)
tree4b3d0c6318cf7be8790289d50244fa0da25a3daa
parent4a5630fe75ac47556c7fd15adfa6a7d9c23d18c8 (diff)
Improved NoReverseMatch error message when invalid args/kwargs are passed.
Refs #8611 git-svn-id: http://code.djangoproject.com/svn/django/trunk@11482 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/urlresolvers.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
index 4f9eb982e2..eedb8f126c 100644
--- a/django/core/urlresolvers.py
+++ b/django/core/urlresolvers.py
@@ -287,8 +287,17 @@ class RegexURLResolver(object):
candidate = result % unicode_kwargs
if re.search(u'^%s' % pattern, candidate, re.UNICODE):
return candidate
+ # lookup_view can be URL label, or dotted path, or callable, Any of
+ # these can be passed in at the top, but callables are not friendly in
+ # error messages.
+ m = getattr(lookup_view, '__module__', None)
+ n = getattr(lookup_view, '__name__', None)
+ if m is not None and n is not None:
+ lookup_view_s = "%s.%s" % (m, n)
+ else:
+ lookup_view_s = lookup_view
raise NoReverseMatch("Reverse for '%s' with arguments '%s' and keyword "
- "arguments '%s' not found." % (lookup_view, args, kwargs))
+ "arguments '%s' not found." % (lookup_view_s, args, kwargs))
def resolve(path, urlconf=None):
return get_resolver(urlconf).resolve(path)