Tim's solution would obviously work, but it sounds to me like you would need to manually configure a subdomain (including a copy of settings.py) for each user. Widoyo's solution (or rather, Ross Poulton's linked solution) would also work but requires quite a lot of boilerplate code in your views to retrieve the current username.

I don't know what web server you intend to use, but could you not handle the problem at this level by using URL rewriting? It shouldn't be hard to write a rule[1] to map http://myuser.mydomain.com/* to http://www.mydomain.com/user/myuser/*. Once you've done this, you can use standard a Django URLConf and not worry about what the actual domain name is :)

HTH,
-Andy

[1]: There's an example of what is essentially this rule for Apache here: http://muffinresearch.co.uk/archives/2006/08/20/redirecting-subdomains-to-directories-in-apache/


        Tim Sawyer <mailto:list.dja...@calidris.co.uk>
29 December 2010 17:58


I did this with one settings.py per subdomain, using the sites framework. So each settings.py had a different SITE_ID.

Here's how to limit admin to a given user's records:

http://drumcoder.co.uk/blog/2010/oct/02/user-specific-data-admin/

This helps with droplists in admin:

http://drumcoder.co.uk/blog/2010/oct/02/limiting-records-django-admin/

The above posts also show how to use a manager to limit the records, so you can do

Blog.objects.all() to get all records across all sites, and
Blog.on_site.all() to get the records only for the current site.

Hope that helps,

Tim.



------------------------------------------------------------------------

        Parra <mailto:parro...@gmail.com>
23 December 2010 04:29


Hello,

I'm new to Django and thinking of using it for a project.

In this project, there will be accounts and each account will have a
subdomain.
Based on the subdomain/account, the user will just see the records
that belongs to them.
The tables will be unique for all accounts, so there should be a field
to identify the account/records....

I think this is maybe a common task and that there is a "right" way to
do this...

Can someone give me some tips on where to get started with this ??

Thanks,

Marcello

------------------------------------------------------------------------

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

<<inline: compose-unknown-contact.jpg>>

Reply via email to