6.2.4 The NoReverseMatch
Exception
When URL reversal doesn’t work, Django raises a NoReverseMatch
exception. In Example 6.11, we ask for a URL pattern name that doesn’t exist.
>>> from django.core.urlresolvers import reverse >>> reverse('no_such_url_pattern')
Django outputs the stack trace for the error, as shown in Example 6.12. The important bit is at the very end of the output (formatted in the example for convenience).
django.core.urlresolvers.NoReverseMatch: Reverse for 'no_such_url_pattern' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Django could not find ...
Get Django Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.