Error: You must either define the environment variable DJANGO_SETTINGS_MODULE...

时间:2024-03-14 08:58:50

IDEA或PyCharm运行Django项目报错Error: You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings

几个主要的检查点:

Error: You must either define the environment variable DJANGO_SETTINGS_MODULE...
Error: You must either define the environment variable DJANGO_SETTINGS_MODULE...
检查Run Configurations里面Environment variable,有没有DJANGO_SETTINGS_MODULE配置

Error: You must either define the environment variable DJANGO_SETTINGS_MODULE...
检查Project Structure里面Modules和Facets配置的项目路径是否正确
Error: You must either define the environment variable DJANGO_SETTINGS_MODULE...

Error: You must either define the environment variable DJANGO_SETTINGS_MODULE...