How to check the TEMPLATE_DEBUG flag in a django template?

前端 未结 6 732
既然无缘
既然无缘 2020-12-04 15:31

Do you know if it is possible to know in a django template if the TEMPLATE_DEBUG flag is set?

I would like to disable my google analytics script when I am running my

6条回答
  •  悲哀的现实
    2020-12-04 16:02

    Django 1.9+

    settings.py:

    INTERNAL_IPS = (
        '127.0.0.1',
    )
    

    Templates:

    {% if debug %}
    

    https://docs.djangoproject.com/en/dev/ref/settings/#internal-ips says:

    A list of IP addresses, as strings, that:

    • Allow the debug() context processor to add some variables to the template context.

    The debug context processor is in the default settings.py.

提交回复
热议问题