Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Improved NoReverseMatch error message when invalid args/kwargs are pa…


Refs #8611

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4b82421a8503788b8a9ea517525ca3fc44de2e55 1 parent 4a5630f
@spookylukey spookylukey authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 django/core/
11 django/core/
@@ -287,8 +287,17 @@ def reverse(self, lookup_view, *args, **kwargs):
candidate = result % unicode_kwargs
if'^%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)

0 comments on commit 4b82421

Please sign in to comment.
Something went wrong with that request. Please try again.