I have been doing lots of Googling on this topic and have gone through plenty of Django docs, but I can't seem to find a decent answer to what seems like ought to be a very simple question with a simple solution. So hopefully a Django vet out there can help.
Lets say I have the following urlconf:
urlpatterns = patterns('',
....
url(r'^directory/users/$', UserView.as_view(), name='users'),
url(r'^directory/users/(?P<user_id>[0-9]+)/$',UserView.as_view(), name='users'),
....
)
What I want to be able to do is test from within a template which pattern was followed, something like this:
{% if name_of_last_followed_url_pattern == 'users' %}
....
{% endif %}
Now one would think that Django would stash this away somewhere and be able to spit it back out to me. But I cannot find anything that corresponds to "name_of_last_followed_url_pattern" anywhere in the docs or in my searches. Any ideas how I might access this (or if not provided, why not)?