django.core.exceptions.AppRegistryNotReady:应用程序尚未通过Apache的Django用户数据库身份验证进行加载

时间:2019-01-22 12:00:46

标签: django apache mod-wsgi django-2.1

我仅用一个应用程序创建了一个django项目。我没有在应用程序中进行任何更改。仅将应用程序添加到设置中,并更新了静态和媒体网址。

完成迁移并创建了超级用户。

我已经根据Authenticating against Django’s user database from Apache配置了apache(version:2.4.29)和mod_wsgi(4.5.17)。

但是在Apache错误日志中出现以下错误。

Traceback (most recent call last):
  File "/home/User1/Documents/test/check_apache/check_apache/wsgi.py", line 13, in <module>
    from django.contrib.auth.handlers.modwsgi import check_password
  File "/home/User1/Documents/test/lib/python3.6/site-packages/django/contrib/auth/handlers/modwsgi.py", line 5, in <module>
    UserModel = auth.get_user_model()
  File "/home/User1/Documents/test/lib/python3.6/site-packages/django/contrib/auth/__init__.py", line 165, in get_user_model
    return django_apps.get_model(settings.AUTH_USER_MODEL, require_ready=False)
  File "/home/User1/Documents/test/lib/python3.6/site-packages/django/apps/registry.py", line 197, in get_model
    self.check_apps_ready()
  File "/home/User1/Documents/test/lib/python3.6/site-packages/django/apps/registry.py", line 132, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")

请在下面找到文件 wsgi.py

import os
import mod_wsgi

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'check_apache.settings')
from django.contrib.auth.handlers.modwsgi import check_password
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

from django.contrib.auth.handlers.modwsgi import check_password触发了错误。

Apache配置文件000-defaults.conf

在媒体URL上启用了身份验证。因此,我希望apache配置工作正常。如果您要检查,我已经创建了github repository

我从一个包含许多应用程序和其他django模块的更大项目中得到了这个问题。但是我仍然可以通过这个简单的项目重现同样的问题。谢谢您,请您能帮我解决这个问题!

0 个答案:

没有答案