django运行时报错处理方法

django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, 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", "project_name.settings")# project_name 项目名称
django.setup()

posted @ 2019-10-12 11:14  星空之主  阅读(418)  评论(0编辑  收藏  举报