In Django, you want a view name with a namespace from the URL path (for example, / admin / auth / user / 1 / change /).
It also displays the parsed arguments.
from django.core.urlresolvers import get_resolver
path_info = '/admin/auth/user/1/change/'
resolver = get_resolver(None) #Modern Django doesn't have to have arguments
resolver_match = resolver.resolve(path_info)
print('view_name:', resolver_match.view_name)
callback, callback_args, callback_kwargs = resolver_match
print('args:', callback_args, ', kwargs:', callback_kwargs)
result
view_name: admin:auth_user_change
args: ('1',) , kwargs: {}
Recommended Posts