报错代码:“django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.”
解决方案:
1、pycharm上点“击编辑配置”,如下图所示:
2、“运行/调试环境”页面,“环境变量(E)”栏添加环境变量:DJANGO_SETTINGS_MODULE=projecname.settings,与前一个环境变量用英文状态下的分号(;)隔开,其中“projecname”指的是你的项目名称,例如,我的为:DJANGO_SETTINGS_MODULE=ApiTest.settings,如下图所示: