CorsMiddleware is not working in Django 1.10
See original GitHub issueCorsMiddleware is not working with Django 1.10. If it is inserted into the list of middlewares in settings file, an error occurs such as below.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x110eaa158>
Traceback (most recent call last):
File "/Users/adrysn/.pyenv/versions/neumann35/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Users/adrysn/.pyenv/versions/neumann35/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 142, in inner_run
handler = self.get_handler(*args, **options)
File "/Users/adrysn/.pyenv/versions/neumann35/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler
handler = super(Command, self).get_handler(*args, **options)
File "/Users/adrysn/.pyenv/versions/neumann35/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 64, in get_handler
return get_internal_wsgi_application()
File "/Users/adrysn/.pyenv/versions/neumann35/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 49, in get_internal_wsgi_application
return import_string(app_path)
File "/Users/adrysn/.pyenv/versions/neumann35/lib/python3.5/site-packages/django/utils/module_loading.py", line 20, in import_string
module = import_module(module_path)
File "/Users/adrysn/.pyenv/versions/3.5.0/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/Users/adrysn/lablup/neumann/neumann/wsgi.py", line 17, in <module>
application = get_wsgi_application()
File "/Users/adrysn/.pyenv/versions/neumann35/lib/python3.5/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "/Users/adrysn/.pyenv/versions/neumann35/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 153, in __init__
self.load_middleware()
File "/Users/adrysn/.pyenv/versions/neumann35/lib/python3.5/site-packages/django/core/handlers/base.py", line 82, in load_middleware
mw_instance = middleware(handler)
TypeError: object() takes no parameters
This error is probably due to the changed style of middleware introduced in Django 1.10: https://docs.djangoproject.com/en/1.10/topics/http/middleware/.
The middleware class should be updated to comply with the new style.
For the moment, one can replace object
to MiddlewareMixin
to enable the middleware.
from django.utils.deprecation import MiddlewareMixin
class CorsPostCsrfMiddleware(MiddlewareMixin):
...
class CorsMiddleware(MiddlewareMixin):
...
Issue Analytics
- State:
- Created 7 years ago
- Reactions:8
- Comments:14 (5 by maintainers)
Top Results From Across the Web
CorsMiddleware is not working in Django 1.10 · Issue #102
CorsMiddleware is not working with Django 1.10. If it is inserted into the list of middlewares in settings file, an error occurs such...
Read more >django-cors-middleware does not work - Stack Overflow
The django-cors-middleware allows you to control access to your Django app from different domains. It doesn't let you control access to google.
Read more >django-cors-headers - PyPI
A Django App that adds Cross-Origin Resource Sharing (CORS) headers to responses. This allows in-browser requests to your Django application from other ...
Read more >Middleware - Django documentation
Middleware¶. Middleware is a framework of hooks into Django's request/response processing. It's a light, low-level “plugin” system for globally altering ...
Read more >[Solved]-django-cors-middleware does not work-django
Coding example for the question django-cors-middleware does not work-django.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Apparently django-cors-headers is no longer maintained, django-cors-middleware is a good alternative: https://pypi.python.org/pypi/django-cors-middleware/
Now I’ve been added as maintainer (see #110) I’ve merged Django 1.10 support, and deployed to PyPI at version 1.2.0. Enjoy.