#32605: Custom Middleware Error ====> WSGI application
'<ProjectName>.wsgi.application' could not be loaded; Error importing
module.
-------------------------------------+-------------------------------------
               Reporter:  alimp5     |          Owner:  nobody
                   Type:             |         Status:  new
  Uncategorized                      |
              Component:  Core       |        Version:  3.1
  (System checks)                    |       Keywords:  Middleware, WSGI-
               Severity:  Normal     |  Error, Windows, Django3.1
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Greetings

 Django: 3.1.7
 OS: Windows 10 - 64 bit
 Python: 3.8.6 - 64 bit

 Project Name: coffehouse
 App Names: about, stores, coffe_app

 I was creating a custom middleware for my django project. And after adding
 the path of middleware file to settings.py file (in MIDDLEWARE variable),
 I got error below:

 {{{
 raise ImproperlyConfigured(
 django.core.exceptions.ImproperlyConfigured: WSGI application
 'coffehouse.wsgi.application' could not be loaded; Error importing module.
 }}}


 #### settings.py:

 {{{
 INSTALLED_APPS = [
     'coffe_app.apps.CoffeAppConfig',
     'stores',
     'about',

     'django.contrib.admin',
     'django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.messages',
     'django.contrib.staticfiles',
 ]

 MIDDLEWARE = [
     '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',

     'coffehouse.utils.middleware.CoffehouseMiddleware',    <===
 ]

 }}}

 #### coffehouse\coffehouse\utils\middleware\CoffehouseMiddleware.py:

 {{{
 class CoffehouseMiddleware (object):
     def __init__(self, get_response):
         self.get_response = get_response

     def __call__(self, request):
         response = self.get_response (request)
         return response

     def process_view (self, request, view_func, view_args, view_kwargs):
         pass

     def process_exception (self, request, exception):
         pass

     def process_template_response (self, request, response):
         pass
 }}}


 #### wsgi.py:

 {{{
 import os
 from django.core.wsgi import get_wsgi_application
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'coffehouse.settings')
 application = get_wsgi_application()
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32605>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.5b9a8603c05d5df3de662e50838f2b7b%40djangoproject.com.

Reply via email to