Whaat I Want To Do:
Have a Boolean Variable: has_sidebar to check if I should include the sidebar partial or not
The partial is called in base.html, my base template
view functions should be able to change has_sidebar to declare whether response will be rendered with sidebar or not.
#views.py
def my_func1(request):
has_sidebar = True
return render_to_response('template1.html', {}, context_instance=RequestContext(request))
def my_func2(request):
has_sidebar = False
return render_to_response('template2.html', {}, context_instance=RequestContext(request))
#base.html
{% if has_sidebar %}{%include 'sidebar.html'%}{%endif%}
#template1.html
{% extends 'base.html' %}
#template2.html
{% extends 'base.html' %}
how can I do this? thanks in advance!
NOTE: The HTML layout only allows me to render the sidebar in the base template.
When you return base.html to be rendered, add
from django.shortcuts import render_to_responseto the top of your views.py and put the following in both my_funcs: