django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configur
出现这种“django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.”
情况是没有设置django环境。
解决方法如下:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ywpt.settings") #ywpt.settings根据自己的项目来
import django
django.setup()
from facilityinfo import models 上面先加,再引入model

浙公网安备 33010602011771号