在centos7下安装了pycharm,但是每次在shell窗口输入 import viewclass.models as models 来引入模块,结果报错:
django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing
settings.
但是程序用python manage.py runserver 启动却正常,google里面有好多解决办法,但是都不适用。
解决办法:
在shell窗口输入 python manage.py shell
然后在输入 import viewclass.models as models 来引入。

本文介绍了一种在CentOS7环境下使用PyCharm时遇到的问题:通过shell窗口直接导入Django模块会报错,但在使用python manage.py shell方式下则能正常工作。文中提供了一个简单的解决方案。
2221





