django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.报错原因及解决办法,可能不适用所有人!

**

django.core.exceptions.AppRegistryNotReady: Apps aren’t loaded yet.报错原因及解决办法,可能不适用所有人!

**
寥寥几行,在此浪费了我两个小时…希望后人少走弯路哈哈哈

from moive.models import Course #我的目的是使用命令行进行对数据库的增删改查
具体报错信息:
Traceback (most recent call last):
File “”, line 1, in
File “/home/pyvip/Django2/moive/models.py”, line 7, in
class Department(models.Model):
File “/home/pyvip/.virtualenvs/Django2/lib/python3.5/site-packages/django/db/models/base.py”, line 100, in new
app_config = apps.get_containing_app_config(module)
File “/home/pyvip/.virtualenvs/Django2/lib/python3.5/site-packages/django/apps/registry.py”, line 244, in get_containing_app_config
self.check_apps_ready()
File “/home/pyvip/.virtualenvs/Django2/lib/python3.5/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.

报错原因:
因为使用命令行进行对数据库的增删改查时,没有在项目根目录下运行python manage.py shell 命令 ,直接运行的python 命令,导致报错。

解决方案:
把python 命令直接换成 python manage.py shell 运行则完美解决!

你可能感兴趣的:(报错)