[英]Django: how to exit in settings.py
I have a Django website which has different settings for development and production ( DEBUG
/ SECRET_KEY
, etc). 我有一个Django网站,它有不同的开发和生产设置(
DEBUG
/ SECRET_KEY
等)。 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: 在
settings.py
文件中,如果没有像这样给出预期的设置,我想退出:
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? 这样退出
settings.py
文件是否正确?
你应该提出ImproperlyConfigured
,它会干净地退出应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.