且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何设置DJANGO_SETTINGS_MODULE环境变量?

更新时间:2022-04-05 08:50:13

请勿在应用程序外部进行设置。在 wsgi 文件中输入 DJANGO_SETTINGS_MODULE 变量。每次启动服务器时,都会自动设置此变量。

Do not set it from outside the application. Make a entry for DJANGO_SETTINGS_MODULE variable within your wsgi file. Everytime your server will be started, this variable will be set automatically.

例如:

import os
os.environ['DJANGO_SETTINGS_MODULE'] = '<project_name>.settings'