14

My settings file has:

DEBUG = True

The obvious method:

if DEBUG:
    print 'debug'

Does not seem to work:

global name 'DEBUG' is not defined
Hoa
  • 19,858
  • 28
  • 78
  • 107

1 Answers1

34

As mentioned in the comment, you need to do:

from django.conf import settings

print(settings.DEBUG)
DBedrenko
  • 4,871
  • 4
  • 38
  • 73
zsquare
  • 9,916
  • 6
  • 53
  • 87
  • I am new to django. Can You please explain where I can write this to check my settings.I tried in Python console but it is not giving the right value back. – Lalit Sharma May 08 '20 at 18:08
  • @LalitSharma In `python manage.py shell` of your Django `manage.py` – DBedrenko May 28 '20 at 12:40
  • @DBedrenko thank you, that worked just fine. I was adding it in view and returning the value as api result. That was a mess. – Lalit Sharma May 29 '20 at 18:31