﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18584	Ability to fetch urlname from template context	Cal Leeming	nobody	"Currently to detect what the current urlname is in a template requires adding some code into each view. This is so you can detect what page you are currently on, to place for example CSS classes onto a link to indicate you are on that page.

Really, Django should have the urlname in the request context as standard. I'm currently using the following approach:

{{{

context_processors.py:
def resolve_urlname(request):
    """"""Allows us to see what the matched urlname for this
    request is within the template""""""
    from django.core.urlresolvers import resolve
    try:
        res = resolve(request.path)

        if res:
            return {'urlname' : res.url_name}
    except:
        return {}
}}}


{{{
URL CONF:
url(r'^$', ""sites.vf.views.home"", name = ""home""),
}}}


This then allows me to do things like this:
{{{
<a title=""Home"" href=""{% url home %}"" class=""{% if urlname == ""home""%}sel{% endif %}"">
}}}

Essentially, it allows you to keep all aspects of managing a sites URLs within the same code set and forces the same naming convention.

Could a core developer please confirm if such a patch would be accepted into the core? I feel there's a strong case for this."	Uncategorized	closed	Template system	1.4	Normal	wontfix			Unreviewed	0	0	0	0	0	0
