Tuesday, September 4, 2012

Django multitenant urls configuration

Hello everrybody!

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: http://stackoverflow.com/questions/7194341/optimal-architecture-for-multitenant-application-on-django

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/_qhdKzTLnQcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate