Dry way to apply current class to navigation elements in django templates

Posted by Lakshman Prasad on Stack Overflow See other posts from Stack Overflow or by Lakshman Prasad
Published on 2010-05-26T12:17:41Z Indexed on 2010/05/26 12:21 UTC
Read the original article Hit count: 271

Filed under:
|

Say there are navigations, nav1, nav2, nav3 and many subnavs within each of them.

For the css effect, you need to apply class=current to the currently selected navs.

What is the dry way to do that.

For the subnavs, you can check to see if request.get_full_path is the same as the url that subnav refers to, in the base template.

How can you make it dry for the navigation too.

© Stack Overflow or respective owner

Related posts about django

Related posts about django-templates