Skip to content

Instantly share code, notes, and snippets.

@tigrawap
tigrawap / any_view.py
Created April 17, 2011 09:12
any_view.py
context={"disabled":
{"top_ranked_hospitals":True}
}
@tigrawap
tigrawap / template.html
Created April 17, 2011 09:11
template.html
{% load books_boxes %}
{% if not disabled.top_ranked_books %}
{% top_books %}
{% endif %}
from django import template
register=template.Library()
from books.models import Book
@register.inclusion_tag('boxes/top_books.html',takes_context=True)
def top_books(context):
books=Book.objects.all()
return {'books':hospitals,"display":books}
from cp_control.control import disable
def index(request):
disable("someapp.context_processors.top_ranked") #disable one context proccessor, the rest N-1 will be shown
context_instance=RequestContext(request)
return render_to_response('base.html',context,context_instance)
@tigrawap
tigrawap / control.py
Created April 17, 2011 08:51
as separated app
__author__ = 'tigra'
from django.conf import settings
def disable(module):
module=module, #converting into tuple
cp=set(settings.TEMPLATE_CONTEXT_PROCESSORS)-set(module)
settings.TEMPLATE_CONTEXT_PROCESSORS=tuple(cp);