Ram Rachum
Ram Rachum

Reputation: 88578

Django: Manually getting the view corresponding to a URL

I have a Django project. Given a url, how can I know which view will be dispatched to handle the request?

Upvotes: 4

Views: 338

Answers (1)

jathanism
jathanism

Reputation: 33716

You want django.core.urlresolvers.resolve, which allows you to map an URL to a view and to keep your URL & view logic separate. This is the opposite of django.core.urlresolvers.reverse which allows you to map a view to a URL.

See the documentation for how to use it!

Upvotes: 6

Related Questions