django-rest-frameworkdjango-settingsdjango-middlewaredjango-socialauthdjoser

Issue in django.core.exceptions.ImproperlyConfigured


I added social_django.middleware.SocialAuthExceptionMiddleware

MIDDLEWARE = [
    'social_django.middleware.SocialAuthExceptionMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

Error:

django.core.exceptions.ImproperlyConfigured: WSGI application 'Project2.wsgi.application' could not be loaded; Error importing module.


Solution

  • You defined somewhere in your settings file the following line:

    WSGI_APPLICATION = 'Project2.wsgi.application'
    

    That means you must have under your Project2 directory a wsgi.py file that declare the wsgi application. It should look like this:

    import os
    from django.core.wsgi import get_wsgi_application
    application = get_wsgi_application()
    

    More details in the official doc here.