How to check DEBUG true / false in django template - exactly in layout.html

I would like to highlight the look of some toolbar in layout.html depending on whether DEBUG = True or not.

I know about this answer with django.core.context_processors.debug , but it forces me to use RequestContext instead of Request , which I don't really like, btw how can I use RequestContext for layout.html that extends base.html ?

And in general, is there any better way than the one mentioned or one who has a custom template tag ?

I'm on Django 1.7 now

+22
python django django-templates django-settings
Sep 11 '14 at 9:11
source share
1 answer

In newer versions of Django, you can simply specify specyng INTERNAL_IPS in the settings, for example:

 INTERNAL_IPS = ( '0.0.0.0', '127.0.0.1', ) 

and then in the template:

 {% if debug %} 

since context handlers are responsible for this by default and answers How do I check the TEMPLATE_DEBUG flag in a django template? outdated.

+36
Sep 11 '14 at 9:30
source share



All Articles