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,
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.
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.
Make sure you are in desired python Environment
Get the
requirements.txt
file or thepython modules list
, which are needed to execute django.
Install all the Modules and you shall be good to go.
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
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.
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', ... ]