The Python Oracle

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

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Techno Intrigue Looping

--

Chapters
00:00 How To Check Debug True/False In Django Template - Exactly In Layout.Html
00:33 Accepted Answer Score 86
00:57 Thank you

--

Full question
https://stackoverflow.com/questions/2578...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #django #djangotemplates #djangosettings

#avk47



ACCEPTED ANSWER

Score 86


In newer versions of Django it is possible just by specifying INTERNAL_IPS in settings.

For example:

INTERNAL_IPS = (
    '127.0.0.1',
    '192.168.1.23',
)

and then in template just:

{% if debug %}

because context processors responsible for that by default, and the answers from How to check the TEMPLATE_DEBUG flag in a django template? are bit deprecated.