4👍
✅
Use this snippet (originally taken from djangosnippets.org/snippets/1378/);
>>> from my_projects.tools import resolve_to_name
>>> print resolve_to_name('/some/url')
'app.views.view'
>>> print resolve_to_name('/some/other/url')
'this_is_a_named_view'
😉
33👍
In Django 1.3 and newer you can use resolve function:
from django.core.urlresolvers import resolve
print resolve('/books/').url_name
Source:stackexchange.com