dJango运行项目报错django.core.exceptions.ImproperlyConfigured

dJango

dJango处理运行项目时,django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE 问题处理

**

报错如下:
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.

解决办法如下:
在代码前加入如下语句:

import os,django
os.environ.setdefault(“DJANGO_SETTINGS_MODULE”, “firstProject.settings”)# project_name 项目名称
django.setup()

你可能感兴趣的:(dJango运行项目报错django.core.exceptions.ImproperlyConfigured)