Hoa
Hoa

Reputation: 20438

How can I test whether Django is running in debug mode?

My settings file has:

DEBUG = True

The obvious method:

if DEBUG:
    print 'debug'

Does not seem to work:

global name 'DEBUG' is not defined

Upvotes: 16

Views: 9911

Answers (1)

zsquare
zsquare

Reputation: 10146

As mentioned in the comment, you need to do:

from django.conf import settings

print(settings.DEBUG)

Upvotes: 39

Related Questions