Tutorial by Examples

in myapp/context_processors.py: from django.conf import settings def debug(request): return {'DEBUG': settings.DEBUG} in settings.py: TEMPLATES = [ { ... 'OPTIONS': { 'context_processors': [ ... 'myapp.context_processor...
Assuming you have a model called Post defined in your models.py file that contains blog posts, and has a date_published field. Step 1: Write the context processor Create (or add to) a file in your app directory called context_processors.py: from myapp.models import Post def recent_blog_posts...
Context processor to determine the template based on group membership(or any query/logic). This allows our public/regular users to get one template and our special group to get a different one. myapp/context_processors.py def template_selection(request): site_template = 'template_public.html...

Page 1 of 1