views:

15

answers:

1

I want to modify part of my base navigation menu based on a flag on the user model, without having to include request.user in every single view function in my codebase. The nav menu is part of the base template which every other template extends.

Is there a simple way to do this (if so, I suck at search)? If not, is there a standard workaround?

+1  A: 

If I understand you correctly:

{% if request.user.flag %}
    {% include "nav1.html" %}
{% else %}
    {% include "nav2.html" %}
{% endif %}
Dor
Ah - request is available in all templates automatically? Well that certainly simplifies things - thanks. Makes my question kinda dumb, though...
rfrankel
Actually, it doesn't happen automatically. You'd still need to use RequestContext and add the request context processor: http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-request
Dor