Alan Harper
Alan Harper

Reputation: 803

Django flatpages

I am using Django flatpages and would like to implement some logic in a template based on a user session variable.

eg.

{% if session.my_var %}
    YES
{% else %}
    NO
{% endif %}

Problem is that session object is not defined in flatpage context.

Upvotes: 0

Views: 561

Answers (1)

Simeon Visser
Simeon Visser

Reputation: 122376

Create a TEMPLATE_CONTEXT_PROCESSOR which is then used by the RequestContext (see docs).

def session(request):
    return { 'session': request.session }

Upvotes: 1

Related Questions