1

I am developing a web app using django for server-side. It has clients in android, ios and frontend. I was thinking of using subdomains for differentiating the urls of these clients. The differentiation is due to the fact that responses to urls are different for different clients. I was hoping of being able to do using subdomains like android.example.com, ios.example.com...etc. My subdomains are fixed.

Can you help regarding what approach I should take to achieve this. Some options I have read are

  • Hosting two different project with same database.(Looks quite good for me, but may not be the optimum)
  • Hosting on same instance using sites framework.(Not sure as to how good this option is)
  • Hosting using virtual-host(Really Not able to understand how to achieve this).
  • Using a Sub-domain Middleware, as mentioned in many of answers and also in some Django Snippets.

Please help me with the best option and if possible with links to some tutorials as to how to achieve it. Thanks.

Saransh Mohapatra
  • 9,430
  • 10
  • 39
  • 50

1 Answers1

1

"Using the sites framework" is somehow the same as hosting two projects with the same database. If you would use the sites framework you would have seperate instances for each subdomain which share the same code base and data base, but have to differ in one setting in the first place, which is SITE_ID.

If you're able to run multiple instances this for sure has some advantages:

  • You don't need additional processing via a middleware
  • You can easily choose different settings for each site, eg. different template paths, use different middleware etc, even customize urls per project if necessary
  • You're doing already some kind of load-balancing, as you're directing requests to seperate instances, also if one site crashes it shouldn't affect the others

If you can only run one instance I guess your only choice is using something like a middleware, eg. django-mobile then is maybe something to look in as it offers you some good toolset for determining the type of client etc...

But besides that note that it might not always be the best practice to have seperate domains with the same content when it comes to SEO.

Bernhard Vallant
  • 49,468
  • 20
  • 120
  • 148
  • Thanks. SEO is not at all a criteria as I dont want the search engine to show the urls for mobile clients and all. All I want them to show is the actual url showing in the webpage. I still didn't understand one thing though, should I prefer sites framework or projects. And wont two different projects using the same database with different models be a problem. Just a small concern will it be a problem if the secret key in both the projects be different. – Saransh Mohapatra Jun 15 '13 at 18:50
  • @SaranshMohapatra If the sites should mainly use the same apps etc go with the sites framework... Only if your code base would really differ for every site create seperate projects - but don't do it if it's not necessary, as seperate projects will be hard to maintain... – Bernhard Vallant Jun 15 '13 at 19:29
  • @Bernahard Vallant So basically you are saying to use sites framework. Yeah basically they use the same thing but only differences are for some requests the responses are different for each client. But they are basically the same app with almost everything similar. – Saransh Mohapatra Jun 15 '13 at 19:37