Middleware fails with Django 1.10
See original GitHub issueIf I use the SubdomainURLRoutingMiddleware
middleware with the new MIDDLEWARE = [...]
setting then any view fails with:
Traceback (most recent call last):
File "/home/username/project/test_file.py", line 353, in test_file
HTTP_HOST='subdomain.example.com'
File "/home/username/project/env/local/lib/python2.7/site-packages/django/test/client.py", line 541, in post
secure=secure, **extra)
File "/home/username/project/env/local/lib/python2.7/site-packages/django/test/client.py", line 343, in post
secure=secure, **extra)
File "/home/username/project/env/local/lib/python2.7/site-packages/django/test/client.py", line 409, in generic
return self.request(**r)
File "/home/username/project/env/local/lib/python2.7/site-packages/django/test/client.py", line 476, in request
response = self.handler(environ)
File "/home/username/project/env/local/lib/python2.7/site-packages/django/test/client.py", line 129, in __call__
self.load_middleware()
File "/home/username/project/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 82, in load_middleware
mw_instance = middleware(handler)
TypeError: object() takes no parameters
I believe the middleware may need updating to be compatible with Django 1.10: https://docs.djangoproject.com/en/1.10/topics/http/middleware/#upgrading-pre-django-1-10-style-middleware
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:12
Top Results From Across the Web
Middleware - Django documentation
This document explains how middleware works, how you activate middleware, and how to write your own middleware. Django ships with some built-in middleware...
Read more >Django 1.10.6 - Middleware does not work - Stack Overflow
You can do old style middlewares by inheriting django.utils.deprecation.MiddlewareMixin like class OldMiddleware(MiddlewareMixin): #rest of ...
Read more >Custom Middleware Issue with Mezzanine/Cartridge
So I tried switching to the function-based middleware from the django docs: https://docs.djangoproject.com/en/1.10/topics/http/middleware/.
Read more >Getting started with Django middleware
First, create a Django project with a single application. Ignore the migrations, examples from this post will not use a database. Create a...
Read more >Custom settings and wsgi in django 1.10 give me error-django
I tried directly in Django 1.10! Initially it showed "TypeError: object() takes no parameters" error. After I changed MIDDLEWARE to MIDDLEWARE_CLASSES in my ......
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
The issue is resolved by replacing
class SubdomainMiddleware(object):
within the middleware.py file. I can open a Pull request to fix this issue if needed.
You can use the fork I created, just install it using:
pip install git+https://github.com/parth-choudhary/django-subdomains.git
Should work fine.