Using django-hosts I managed to put together a simple setup that maps 
subdomains to databases.

First, I have a default database with a table mapping sudomains to database 
name and a middleware that tries to load the correct object based on the 
match provided by django-hosts.

In my settings I have a *placeholder* database that gets replaced by the 
middleware if the subdomain is mapping to a database.

Finally I have a database router that returns the *placeholder* db alias 
when models are subdomain specific.

This setup is working pretty well so far.

Hope it helps!

Le mardi 15 mai 2012 05:30:28 UTC-4, Anthony Briggs a écrit :
>
> Hi Alec,
>
> One of the science experiments on my todo list is to try and set up one of 
> the fancy new database routers (possibly with get_current_site() or 
> similar) and see if I can serve multiple sites+databases from the same 
> Django instance.
>
> Not sure if that helps, or even it it'll work, but if it does it might do 
> what you need.
>
> Cheers,
>
> Anthony
>
> On 9 May 2012 13:02, Alec Taylor <alec.tayl...@gmail.com> wrote:
>
>> Dear Django-developers,
>>
>> I've been using Django for a few months now, and recently—for
>> different projects—started using the web-framework: web2py[1], and the
>> Django project: mezzanine[2].
>>
>> Both advertise as being multi-tenant solutions[3][4].
>>
>> Would it be possible to extend Django to meet this use-case? — Or have
>> I overlooked something and is this possible already?
>>
>> Thanks for all information,
>>
>> Alec Taylor
>>
>> [1] http://www.web2py.com/
>> [2] http://mezzanine.jupo.org/
>> [3] https://groups.google.com/forum/#!topic/mezzanine-users/4XPe5MaD4Fw
>> [4] PyCon 2012 talk: http://youtu.be/M5IPlMe83yI?t=5m32s
>> http://dl.dropbox.com/u/18065445/Slides/PySFTalkSlides.pdf (slide42,
>> see yt for more info)
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django developers" group.
>> To post to this group, send email to django-developers@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-developers+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-developers?hl=en.
>>
>>
>

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

Reply via email to