I'm working with Django's named URL patterns, and was wondering how to fetch the name of the URL pattern that triggered the view. For example, with the following urlpatterns
> I'm working with Django's named URL patterns, and was wondering how to
> fetch the name of the URL pattern that triggered the view. For
> example, with the following urlpatterns
I came across a similar problem when trying to put together my app for
handling menus (since I wanted to be able to specify menu items by url
names). Anyway the following was the method I finally came up with
which seems to work just fine for me -
http://code.google.com/p/greatlemers-django-tools/source/browse/trunk...
> I'm working with Django's named URL patterns, and was wondering how to > fetch the name of the URL pattern that triggered the view. For > example, with the following urlpatterns
> I came across a similar problem when trying to put together my app for > handling menus (since I wanted to be able to specify menu items by url > names). Anyway the following was the method I finally came up with > which seems to work just fine for me - > http://code.google.com/p/greatlemers-django-tools/source/browse/trunk...
> Hope this helps.
> -- > G
That looks like it does exactly what I'm looking for. I wish there were a way to find the URL name without having to call the resolver again, but your method looks pretty fast. Thanks!
Shawn, request.build_absolute_uri() returns a full path like http://hostname/path/goes/here/, but it doesn't tell me the name of the URL pattern that caused the request to be resolved to a particular view.