26

I have developed Multi-tenant SAAS apps in PHP/Laravel but recently I had a challenge to develop one in Django/Python. I am still learning Django though and I really like Django rest framework (DRF). But I have difficulties to figure out the highlighted areas below, If someone shows some light, I will be good to go:

  1. How to handle subdomains/domains and selecting the right tenant db
  2. How to manage and dynamically handle different database in django
  3. Can multi-tenant apps backend still be managed from Django admin interface
  4. I will be using queues and other apps scalling techniques, need tips and tricks if any
  5. Any example out there
  6. Any challenge experience when developing SAAS through Django
Cheruiyot Felix
  • 1,557
  • 5
  • 26
  • 42
  • Have a look at the possible duplicate of your question: [Python / Django multi-tenancy solution][1] [1]: http://stackoverflow.com/questions/19230734/python-django-multi-tenancy-solution – Ber Feb 17 '14 at 10:15
  • Yes, but I realize django-tenant-schemas is only tied to PostgreSQL. Anyway you can handle for MySQL and handle domains properly – Cheruiyot Felix Feb 17 '14 at 10:20

1 Answers1

27

Well...

  1. django-subdomains
  2. There are people who asked in SO questions about dynamic databases in django (including, ahem... me). I'm not entirely sure I understood what you mean by "dynamically handle different database" so I guess just go to the links I just mentioned and pick out the best one for your project. (also - perhaps this is more relevant?)
  3. Check out django-multitenant-schemas and this answer too.
  4. There was a video of the guys behind Disqus (one of the largest django app in the world) explaining how they handle scaling. Here another interesting article on the subject. Also, the legendary SO question Does Django Scale.
  5. (and 6.) Check out this answer

I hope that's detailed enough. I know this might be a disappointing only-links answer, but this is the reality of it - Django is a newer framework, and web development with python is still less common than php. With that in mind, understand that for all the awesomness of django (and it is awesome), with more complex needs there's more you'll have to do yourself.

In this case, you'll have to figure out how to do each part of the way seperatly and then combine it all. You can easily find a way to create a REST django app for example, but then you'll need to figure out how to combine it with another package (such as the above subdomains).

You can find a million examples out there of people doing freaky things with django. It's really powerful (when I learned about dynamic models I was blown away). But the more complex your app, the more you'll need to do yourself.

Pick it up, one step at a time, and come back to SO with specific issues you're having (or the django users google group). Good luck!

Harry Moreno
  • 10,231
  • 7
  • 64
  • 116
yuvi
  • 18,155
  • 8
  • 56
  • 93
  • I have been going through all the suggestions and I this might be close to the answer but not very sufficient. I have realized the way Django ORM binds to the database does not give you a lot of flexibility to manipulate stuff easily the way you want. Do you know of any example/bootstrap where most of the above have been used together? I would like to get and follow good/recommended practice. I think I might also have to switch my db from MySQL to PostgreSQL – Cheruiyot Felix Feb 24 '14 at 11:47
  • That's exactly my point - you have a list of complicated requirements, and you can find a lot of examples for each one of them, but it's the combining part that you're probably going to have to figure out yourself, because django is still kinda new to the neighborhood. As for switching - well, frankly, django *was* created with PostgreSQL from the very begining, and MySQL support was added later. But I have good personal experience with MySQL and django together, so for now you should try and make it work with what you know – yuvi Feb 24 '14 at 11:57
  • One last thing - the ORM allows for almost all the flexibility you need (and allows for raw sql queries if all else fails). It's just a matter of getting to know the small details. However, I won't lie, there are some alternatives claiming to be better (such as [pee-wee](http://charlesleifer.com/blog/shortcomings-in-the-django-orm-and-a-look-at-peewee-a-lightweight-alternative/)), but I can't recommend them. I think you should try to make it work with the ORM before looking at alternatives – yuvi Feb 24 '14 at 11:58
  • Ok. Thanks for the details. If you find anything, please consider updating this post so that it be of help to other guys in future. I promise to do so too as I work on this project. Thanks – Cheruiyot Felix Feb 24 '14 at 12:02