Check if redirect url exists

design-patterns, django, url

Solution

from django.core.urlresolvers import resolve, Resolver404
try:
    resolve(path)
except Resolver404:
    'not found'

Problem

After login user should be redirected to the `?next=%s` url. I want to check if specified url mapped to an existant view. There is `reverse()` function for getting url by view, i need v.v. So, i need the function that Django executes for url pattern match. I see, the question is simple, but i could not find the answer in google.

Original source