tags:

views:

125

answers:

2

Hello all,

I know there are lots of example for how to set http://domainname.com/username url. But how to set http://username.domainname.com url in django?

Thinking a way to have a unique url for each user as http://username.domain.com like http://garry.posterous.com/

Thanks

+3  A: 

As the first step, you need to arrange your DNS server to serve the wildcard domain; this is completely outside Django.

When you managed to do that (i.e. dig garry.posterous.com succeeds), then simply check for the HTTP_HOST request variable in the django view routines.

Martin v. Löwis
thanks, sorry, i didn't mean to serve an wildcard domain, i put wildcard meaning any characters there, i already edited my post to avoid confusion.
+1. I've implemented this in several projects using the technique Martin described, using either custom views or custom middleware to check request.META['HTTP_HOST'].
bryan
A: 

see Using Subdomains with Django: http://www.rossp.org/blog/2007/apr/28/using-subdomains-django/

panchicore