pycharm 里运行 django 工程 You must either define the environment variable DJANGO_SETTINGS_MODULE 错误

pycharm 里运行 django 工程出现错误(在命令行直接运行ok):

django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

pycharm 里运行 django 工程 You must either define the environment variable DJANGO_SETTINGS_MODULE  错误

在Enviroment variables里添加如下信息(xxx 为你的项目名):

 PYTHONUNBUFFERED=1;DJANGO_SETTINGS_MODULE=xxxx.settings

pycharm 里运行 django 工程 You must either define the environment variable DJANGO_SETTINGS_MODULE  错误