django.core.exceptions.ImproperlyConfigured: WSGI application 'application' could not be loaded

前端 未结 14 3200
[愿得一人]
[愿得一人] 2021-02-20 06:19

The scenario is,

I cloned the Django code for OpenShift-V3 from here . When I run the code using python manage.py runserver getting an error as,

相关标签:
14条回答
  • 2021-02-20 06:20

    note that any error in importing modules anywhere prior to starting the wsgi application will also prompt this message, so first look at the trace and start from the top in fixing issues.

    I ported a Django app from python 2.7 to python3 and add all sorts of module import issues, not connected to this issue directly.

    0 讨论(0)
  • 2021-02-20 06:22

    Read carefully, it might say "The above exception was the direct cause of the following exception: ...". And the "above exception" being you forgot to install whitehoise. Run pip install whitenoise, it worked for me.

    0 讨论(0)
  • 2021-02-20 06:23

    Make sure you are in desired python Environment

    Get the requirements.txt file or the python modules list, which are needed to execute django.

    Install all the Modules and you shall be good to go.

    0 讨论(0)
  • 2021-02-20 06:26

    maybe using middleware is the simple way to fix this , this problem mostly happens about cors Policy

    Code:

    class CorsMiddleware(object):
       def __init__(self, get_response):
          self.get_response = get_response
    
       def __call__(self, request):
          return self.get_response(request)
    
       def process_response(self,resp):
          resp["Access-Control-Allow-Origin"] = "*"
          return resp
    
    0 讨论(0)
  • 2021-02-20 06:29
    pip install whitenoise
    

    Although solved my problem. Generally produced while we are moving a project to different virtual enviroments. Sometimes we forgot to install the package & whitenoise just broke the application little bit, because no where it is mentioned that you are missing "whitenoise" module.

    0 讨论(0)
  • 2021-02-20 06:31

    Do you have Django Debug Toolbar

    Remove it and check if the problem goes away. Possible occurences:

    pip uninstall django-debug-toolbar
    
    INSTALLED_APPS = [
        ...
        'debug_toolbar',
        ...
    ]
    
    MIDDLEWARE = [
        ...
        'debug_toolbar.middleware.DebugToolbarMiddleware',
        ...
    ]
    
    
    0 讨论(0)
提交回复
热议问题