from django.conf import settings

然后在代码中使用settings.DEBUG这类常量