I am trying to set up subdomains in a Django project using django-subdomains .
These are the steps I took:
- Installed django subdomains using pip.
- Added "subdomains.middleware.SubdomainURLRoutingMiddleware" to my MIDDLEWARE, just b
- Added SITE_ID to my settings, and also configured SUBDOMAIN_URLCONF
This is my settings.py
import os
I also have this as mysite.urls.py :
from django.conf.urls import url, enable from django.contrib import admin
urlpatterns = [ url(r'^admin/', admin.site.urls),
Anyway, I'm testing all of this with this view:
def index(request): return HttpResponse(request.subdomain)
When I run the python manage.py runserver , I get an error in the name. The full trace in my console can be found here:
Link Pastebin
Unhandled exception in thread started by <function wrapper at 0x1026ad2a8> Traceback (most recent call last): File "/Users/user/mysite/myvenv/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/Users/user/mysite/myvenv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 142, in inner_run handler = self.get_handler(*args, **options) File "/Users/user/mysite/myvenv/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 27, in get_handler handler = super(Command, self).get_handler(*args, **options) File "/Users/user/mysite/myvenv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 64, in get_handler return get_internal_wsgi_application() File "/Users/user/mysite/myvenv/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 49, in get_internal_wsgi_application return import_string(app_path) File "/Users/user/mysite/myvenv/lib/python2.7/site-packages/django/utils/module_loading.py", line 20, in import_string module = import_module(module_path) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/Users/user/mysite/mysite/wsgi.py", line 16, in <module> application = get_wsgi_application() File "/Users/user/mysite/myvenv/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application return WSGIHandler() File "/Users/user/mysite/myvenv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 153, in __init__ self.load_middleware() File "/Users/user/mysite/myvenv/lib/python2.7/site-packages/django/core/handlers/base.py", line 82, in load_middleware mw_instance = middleware(handler) TypeError: object() takes no parameters
What am I doing wrong? Am I missing a step in my installation? Any help is appreciated!