django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APP 报错解决办法
场景:我在pycharm控制台(python Console)输入from fruits.models import goods时报错
报错信息:django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
翻译:django.core.exceptions.ImproperlyConfigured:请求设置 INSTALLED_APPS,但未配置设置。您必须在访问设置之前定义环境变量 DJA NGO_SETTINGS_MODULE 或调用 settings.configure()。
错误原因:在运行pycharm时,选择的文件不对。
解决办法:创建启动器。在右上角切换到以项目名命名的文件夹下(Django项目),点击运行。
参考:http://wjhsh.net/erchun-p-14332777.html