models插入数据问题


使用Pycharm编码,直接tests.py编写插入数据,报错: 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. 说是settings的原因:修改: import os import django os.environ.update({"DJANGO_SETTINGS_MODULE": "config.settings”}) django.setup() 然后运行,还是报错: raise AppRegistryNotReady("Apps aren't loaded yet.")django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. 搜了好久都是说diango没有setup原因,但是我执行了。不知道怎么搞了,请各种给个思路

  • 目前还没有回复
添加一条新回复
登录 或者 注册 后发表回复