Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if redirect url exists

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.

like image 318
night-crawler Avatar asked Dec 21 '22 23:12

night-crawler


1 Answers

from django.core.urlresolvers import resolve, Resolver404
try:
    resolve(path)
except Resolver404:
    'not found'
like image 183
okm Avatar answered Dec 28 '22 06:12

okm