我如何解决错误: raise AppRegistryNotReady("Models are not loaded yet.") django.core.exceptions.AppRegistryNotReady: Models are not loaded yet. 我有:
- Django==2.0.13
- django-oauth-toolkit==1.2.0
- 蟒蛇==3.6
我运行命令 manage.py runserver 并接收回溯:
Traceback (most recent call last):
File "xxx/python3.6/site-packages/django/apps/registry.py", line 112, in populate
app_config.import_models()
File "xxx/python3.6/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "xxx/models.py", line 20, in <module>
from oauth import constants, oauth2_internal, utils
File "xxx/oauth2_internal.py", line 15, in <module>
oauthlib_core = get_oauthlib_core()
File "xxx/lib/python3.6/site-packages/oauth2_provider/oauth2_backends.py", line 194, in get_oauthlib_core
validator = oauth2_settings.OAUTH2_VALIDATOR_CLASS()
File "xxx/lib/python3.6/site-packages/oauth2_provider/settings.py", line 143, in __getattr__
val = perform_import(val, attr)
File "xxx/lib/python3.6/site-packages/oauth2_provider/settings.py", line 97, in perform_import
return import_from_string(val, setting_name)
File "/xxx/lib/python3.6/site-packages/oauth2_provider/settings.py", line 109, in import_from_string
module = importlib.import_module(module_path)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/xxx/oauth2_validators.py", line 3, in <module>
from oauth2_provider import oauth2_validators
File "/xxx/lib/python3.6/site-packages/oauth2_provider/oauth2_validators.py", line 41, in <module>
Application = get_application_model()
File "xxx/lib/python3.6/site-packages/oauth2_provider/models.py", line 400, in get_application_model
return apps.get_model(oauth2_settings.APPLICATION_MODEL)
File "xxx/lib/python3.6/site-packages/django/apps/registry.py", line 190, in get_model
self.check_models_ready()
File "xxx/python3.6/site-packages/django/apps/registry.py", line 132, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
Process finished with exit code 1