On Tuesday, February 3, 2015 at 4:56:09 PM UTC-8, Dean De Leo wrote:
>
>  Hi, 
> I am new to Django and I am still going through the tutorial. I've tried 
> to set up a context processor for the following scenario, and I would like 
> to obtain some confirmation if this is a proper solution or I am doing some 
> mess..
> In my base template with a header there is a navigation bar. A single 
> button should be highlighted among the others depending in the current 
> section / page in the website:
>

To me, this feels overly complex. Here's how I do current element selection 
in navigation, without context processors, by passing variables during the 
navigation's include statement. It does make templates a bit more verbose, 
but seems very clear and simple. 

In each page template:

{% block app_nav %}
{% include "dirapp/include/nav.html" with active_tab='something' %}
{% endblock app_nav %}

In the navigation:

<a href="{% url 'foo' %}"
    class="list-group-item {% if active_tab == 'something' %}active{% endif 
%}">Foo
</a>





-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1c039e95-c4e2-41dd-94ec-dc720a122cba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to