tools工具运行报错
看视频import_data的代码,自己也写了一个import_data工具自动把文章导入数据库,但是好像导入models模块出问题了
下面是我的代码:
import os import sys sys.path.append(r'E:\Python\Pycharm\django_introduction') from blog.models import Article
import_data.py 在tools目录下,tools和templates同级(models.py在templates下)
报错提示是:
Traceback (most recent call last): File "E:/Python/Pycharm/django_introduction/tools/import_data.py", line 5, in <module> from blog.models import Article File "E:\Python\Pycharm\django_introduction\blog\models.py", line 5, in <module> class Article(models.Model): File "D:\Python\Python37-32\lib\site-packages\django\db\models\base.py", line 100, in __new__ app_config = apps.get_containing_app_config(module) File "D:\Python\Python37-32\lib\site-packages\django\apps\registry.py", line 244, in get_containing_app_config self.check_apps_ready() File "D:\Python\Python37-32\lib\site-packages\django\apps\registry.py", line 127, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
麻烦老师帮忙看一下是怎么回事,嘻嘻嘻