Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create sub domain for each user in Django

I want users create their own account and users should get their own like user.foo.com and different point to different template folder. Is it possible in Django. I quite new to Django

like image 240
Krpaum Avatar asked Jul 01 '11 02:07

Krpaum


1 Answers

The answer provided by Andre isn't exactly correct. You will indeed need a wildcard domain, most decent providers will allow this including GoDaddy (IE this is not a limitation you should be terribly concerned with).

"To do this directly, you'll need to run Django under a user account that has write access to your webserver's configuration file, which is really not recommended. Assuming all the hosts are on the same machine, you could do this indirectly, such as queuing requests and have someone manually approve them and edit the file, or have a script run through cron and re-write the server configuration every X minutes/hours/days."

This is completely wrong in basically every way. In fact all you need to pull this off is this:Subdomain Middleware. Simply couple that with an appropriate webserver config to accept requests to *.example.com and you have the necessary variable to take your queue off of in every view

like image 100
John Avatar answered Oct 10 '22 09:10

John