My settings file has:
DEBUG = True
The obvious method:
if DEBUG:
print 'debug'
Does not seem to work:
global name 'DEBUG' is not defined
As mentioned in the comment, you need to do:
from django.conf import settings
print(settings.DEBUG)