Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 23, 2010 04:30:02

P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Subdomain/Accounts


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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Dec. 23, 2010 14:13:22

w.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Subdomain/Accounts


May be this link will help you:http://www.rossp.org/blog/2007/apr/28/using-subdomains-django/Widoyo

On Dec 23, 11:29 am, Parra <parro...@gmail.com> wrote:
> Can someone give me some tips on where to get started with this ??
>

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Dec. 29, 2010 17:58:30

Tim S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Subdomain/Accounts


I did this with one settings.py per subdomain, using the sitesframework. 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, soyou can doBlog.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.

On 23/12/10 04:29, Parra wrote: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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 Dec. 29, 2010 18:20:02

Andy S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Subdomain/Accounts


Tim's solution would obviously work, but it sounds to me like you wouldneed to manually configure a subdomain (including a copy of settings.py)for each user. Widoyo's solution (or rather, Ross Poulton's linkedsolution) would also work but requires quite a lot of boilerplate codein your views to retrieve the current username.I don't know what web server you intend to use, but could you not handlethe problem at this level by using URL rewriting? It shouldn't be hardto write a rule to maphttp://myuser.mydomain.com/*tohttp://www.mydomain.com/user/myuser/*. Once you've done this, you canuse standard a Django URLConf and not worry about what the actual domainname is :)HTH,
-Andy: There's an example of what is essentially this rule for Apachehere: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:58I did this with one settings.py per subdomain, using the sitesframework. 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 doBlog.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 athttp://groups.google.com/group/django-users?hl=en.<<inline: compose-unknown-contact.jpg>>

Offline

#5 Dec. 29, 2010 19:19:12

Tim S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Subdomain/Accounts


That's a cunning plan, nice one Andy!I'd use that if I did it again - a virtual host instance per subdomainuses lots of memory on a VPS...Tim.

On 29/12/10 18:19, Andy Shaw wrote: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 to maphttp://myuser.mydomain.com/*tohttp://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

: 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 athttp://groups.google.com/group/django-users?hl=en.--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 21st of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support