I have a Django website which has different settings for development and production ( DEBUG
/ SECRET_KEY
, etc). Production provides these settings with environmental variables. In the settings.py
file I want to exit if the expected settings aren't given like so:
if not DEBUG and SECRET_KEY == DEFAULT_SECRET_KEY:
sys.exit("SECRET_KEY must be set when DEBUG = False")
Is it correct to exit in the settings.py
file like this?
你应该提出ImproperlyConfigured
,它会干净地退出应用程序。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.