I am trying to add some simple tenancy support to an app, creating an Account model which has a string 'tenant' to be read from the request url and identify the tenant in the system:
tenant.example.com/* -> www.example.com/tenant/* (rewritten by apache)
I wrote a simple middleware to capture this /tenant/ from request.path and add a request.account object to be worked with.
My problem is my url mapping.
I tried this:
url(r'^(?P<tenant_id>[\w\-]+)/', include('project.urls_tenant')),
and defined some simple urls inside urls_tenant.py:
url(r'^app1/', include('project.app1.urls')),
url(r'^app2/', include('project.app2.urls')),
When I try to access any page, I get an error message:
generic_view_method() got an unexpected keyword argument 'tenant_id'
because it doesn't (and really shouldn't) expect tenant_id as a parameter.
If I hardcode tenant_id in the urls.py file as /test_tenant/ everything works fine.
What am I doing wrong and how to fix it, so the request and the response gets processed normally?
Thank you guys pretty much. I used this as reference: optimal architecture for multitenant application on django