2

I have created a django project with only one application. I haven't made any changes in the application. Only added the application to the settings and updated static and media urls.

Migration is done and super user was created.

I have configured apache(version:2.4.29) and mod_wsgi(4.5.17) according to Authenticating against Django’s user database from Apache.

But getting the following error in apache error log.

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.")

Please find files below 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()

Error is triggered from from django.contrib.auth.handlers.modwsgi import check_password.

apache config file 000-defaults.conf

Authentication is enabled on the media url. So I hope the apache configuration is working fine. I have create a github repository if you would like to check.

I got this issue from a bigger project with many application and other django modules. But I could still reproduce the same issue with this simple project. Can you please help me to resolve this issue, thanks in advance!

Binoy
  • 79
  • 1
  • 2
  • 6
  • 1
    `from django.contrib.auth.handlers.modwsgi import check_password` should be called after `get_wsgi_application()`. Seems a mistake in the [documentation](https://groups.google.com/d/msgid/django-users/bfdc8e5e-d433-4467-9888-74630f4dfebf%40googlegroups.com) according to [django users](https://groups.google.com/forum/#!forum/django-users). – Binoy Jan 29 '19 at 12:59
  • that was what was causing the problem for me, can you put that in an answer, or I will! – daphtdazz Sep 28 '19 at 18:57

0 Answers0