This video has been replaced please see • How to get Django Tena... for the new version. This video explains how you can use PostgreSQL schemas with Django using the Django Tenant library.
Hi Tom, Thanks for this video. At last I found it after so long been searching for it. Please create a complete multi tenant app. BR, I am Nyoman, from Bali, Indonesia
Please, could anyone share how they managed to make a view for registering a tenant and it's superuser ?! I've been struggling with this for days, with or without DRF , idk what to do... I have already managed to write a signal to create both tenant and superuser but still don't know how to give superuser a password !
Man, I'm simultaneously very thankful and pissed at this, hours later, and still can't get it to work. Please add to the description that you need to install Postgres (and whether inside or outside of venv). Also at 10:05 you mention something you did outside of the tutorial but which is crucial to it, wtf, who does that >:(
Really appreciate your work. I'm trying to get django tenants up with a custom user model. Should the custom User Model be in both tenant and shared apps or only in the shared apps?
Thanks, Tom for sharing this tutorial. I am looking for a solution to use URL parameters instead of subdomains. Eg: tenant app 1 - 127.0.0.1:8000/tenant/1/..... tenant app 2 - 127.0.0.1:8000/tenant/2/..... can you please help me?
@@tomspythonanddjango6269 Thank you. I am unable to make make the subdomains work on Heroku. I am not very deep in this area. I have built an awesome API with Django-Tenants/Django rest_framework and I have also added Django channels. After some sweats, I have it on Heroku and I can access the public domain. But I am not able to access any tenant-specific domain like famv.my-app.herokuapp.com (I don't pay yet for more dynos). Can you please share an idea with me to make the subdomains work? Thank you for your help.
@@tomspythonanddjango6269 I make it work wow. I have learned so much by deploying an api powered by Django/Django-tenants/Django-channels and make it work I feel like making a video tutorial about the process. hahah that was cool
@@poormancodespmc4598 Hey brother, I am trying to create a multi tenant application but not able to access the apis by the other computer on the same network. Please help if you know anything about this.
## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost 127.0.0.1 www.dtdemo.local 127.0.0.1 t1.dtdemo.local 127.0.0.1 t2.dtdemo.local 127.0.0.1 t3.dtdemo.local 127.0.0.1 t4.dtdemo.local
This a wonderful video. It worked like a charm. Thank you very much. Would you please make a video on how to add users to be linked from person to Django User as OneToOne relationship. Thanks again.
Thanks for this great tutorial. Have a question, I developed my project based on this tutorial. I need to integrate celery so as to send reminders weekly or daily to each tenant. E.g If a tenant has a ToDo due tomorrow, the specific tenant gets the notification and the others don't. Any material I can use for such? Thanks in advance.
@@thomasturner2279 Thank you so much for your reply. I've asked this to many of the people but you have only replied. I like to have contact with you for learning django. Shall i contact you through mail or skype. Kindly reply for this post also. If you are ok i'll give my skype id to you. Once again thanks for ur support.
Hi could you explain why in your case you left out the TenantAdminMixin when registering in admin as the docs include it: class ClientAdmin(TenantAdminMixin, admin.ModelAdmin). I followed your example and everything works fine but I realised I get errors if I include this TenantAdminMixin on trying to add Persons to any tenants. Is there any issues with leaving the mixin out?
Hi Tom. Thank you for the great package Django-tenants. I am implementing a project with it, a saas app. The challenge I am facing now is to give the clients the possibility to add their own apps. What I mean, I could allow the client X to add an app "Finance management", but when I will append the new app in the Tenants apps list, it will be available for all the other clients, not just the client X. That behavior would be annoying for the other clients who are not necessarily interested in it. Is there a way to do that with Django-tenants now? Just like Salesforce does, give the opportunity to add app/objects/tabs and so on for a specific client. I can create the logic for that the only concern is how to display the app only for the client who created it not all the clients. I hope the question is clear and you will find a moment to help me. Greetings from Haiti!
Not sure. I personal just unlock parts of my app with a table of add ons. However every tenant still gets all the database tables even if they don't need them. I hope this helps
Good One Tom. If you can extend this app with user login/multi dashboard you will rock the CZcams. Quality content related to SaaS don't exist for django on CZcams.com.
Hi Tom! I can't serve my app on Apache using mod_wsgi daemon mode. It works running at runserver mode test. The Apache configuration in the docs didn't work for me. Do you have any help? Thanks for the video!
This is very timely indeed! I'm trying to get django tenants up with allauth and boy, I have sooooo many questions! For instance, in the docs, the auth and session apps are only in the SHARED_APPS, but here they show also in TENANT_APPS as well. What is the consequence/reason of doing this?
@@tomspythonanddjango6269 Yes, that I got... it's the behavior of the apps appearing twice that confuse me. Like auth, for instance: does it mean I can have users that are global across all tenants and users that are tenant-specific?
Fernando Cordeiro yes and no to the users in the public. The problem is if you go both is that users will have the same is as the tenant users gets. Personally I would have the users only in the tenant. There is a project called django tenant users which is worth looking at I don’t use it however I know lots do.
I did the same. Everything is ok. server is running without any error. but my page is not opening. Request Method: GET Request URL: 127.0.0.1:8000/ No tenant for hostname "127.0.0.1" These errors are showing
Just add a CreateView? Or a function based view and overtide the form_valid(). Then just create the objects that way. The tenant shema gets created when you call the save method.
Hallo Tom thanks to you i could implement multitenancy in django, but how to get my frontend (vue.js) to understand the tenant domains? in other word how to enable the frondend to serve all the other domains? any idea or a reference page that could help? thanks a lot!
Hi Mannar, I am doing the same using vue as my frontend and django-tenants as backend with postgres, working with some api, kind of not able to completely figure out the steps. if you wish, we can collaborate - gs_amin_iut@yahoo.com
@@amintalukder8583 Hello Amin, i figured it out, in my Vue Frontend there is something called base url, there i can inject the domain: t1.my-domain.com. Thanks :)
Thanks @@thomasturner2279 Here it is claimed that your approach is not scalable. Am I missing something ? czcams.com/video/RKSwjaZKXL0/video.html Is it really just only the shared table architecture scalable?
@@erdem.demirci I will watch it later however from what I see he is wrong. The problem with shared architecture is that you have to put a ID of some kind in a lot of tables and there is more chance of data being seen by another client. Years ago I have designed systems like this and it was a nightmare! With tenants you isolate the data of each customer and is easier to manage.
@@thomasturner2279 For now, scalability is more important than isolation, so my concern is whether your approach is scalable. Is "Django-tenants" suitable for scaling? Meanwhile, we look forward your video series to learn more . Thanks
Thank you for your tutorial ! It really helped me, but I'm having trouble to access my server. My domain's name is: test.local. When I type test.local:8000 on the browser. I'm using swagger api to document my API. Can you please help me?
@@thomasturner2279 thank you very much ! Yesterday I saw one of your answers here showing how was your host file and I managed to do mine here. Can you please tell me, how can I redirect the tenant to its host after user registration? I’m getting the error like the tenant wasn’t created (but it was, I checked at database) and the page is not redirected. Appreciate any help
Hi Tom, Thanks Tom for this tutorial, While launching my application using below hosts after creating schema , my server is up but the page is not loading. t1.postgres.local:8000 t2.postgres.local:8000 Could you please help me to resolve this?
You may need to edit the `/etc/hosts` file on your computer so that `t1.postgres.local` and `t2.postgres.local` are redirected to localhost. (Also note that when editing the `/etc/hosts` file, you may need to do so with `sudo`, as it may be protected.) For example, here's what my `/etc/hosts` looks like. I followed Tom's tutorial and set up the domain for t1 and t2 to be `t1.myapp.local` and `t2.myapp.local`. 127.0.0.1 localhost 127.0.0.1 t1.myapp.local 127.0.0.1 t2.myapp.local I hope this helps!
You can put person.html in a folder called `templates` that is inside of `myclientapp`. Make sure to include an empty file called `__init__.py` inside of `templates` so that django can discover it. So, to summarize: your file structure will look something like this: myclientapp/ `--> templates/ `------> __init__.py `------> person.html Hope this helps!
@@AjibolaLDonjibson Yes, was wondering how you managed to do it! :D Something i'm looking at doing myself as i'm building an web app with django-tenants :) Thanks for getting back me!
Keep it up.. your voice matches the authority required on teaching. create MOAR
Thank Tom! for next step can you show me how to create rest api using django-tenant. and whether basic concepts such as relations can be applied here
PLEASE FOR THE LUV OV LARD SOMEONE SHOW US HOW TO USE IT WITH DRF
Thanks a lot. This complements the docs real well as they are not very straighforward and interactive tutorial just throws errors
Hi Tom,
Thanks for this video.
At last I found it after so long been searching for it.
Please create a complete multi tenant app.
BR,
I am Nyoman, from Bali, Indonesia
Thank you! That was brilliant.
Please, could anyone share how they managed to make a view for registering a tenant and it's superuser ?! I've been struggling with this for days, with or without DRF , idk what to do... I have already managed to write a signal to create both tenant and superuser but still don't know how to give superuser a password !
Man, I'm simultaneously very thankful and pissed at this, hours later, and still can't get it to work. Please add to the description that you need to install Postgres (and whether inside or outside of venv). Also at 10:05 you mention something you did outside of the tutorial but which is crucial to it, wtf, who does that >:(
maybe I'm just curvy-handed. Either way thank you for helping others and contributing to open source community.
ok so in your hostfile, did you put:
127.0.0.1 t1.dtdemo.local
127.0.0.1 t2.dtdemo.local
etc
or is there a way to open it up for all subdomains?
Really appreciate your work. I'm trying to get django tenants up with a custom user model. Should the custom User Model be in both tenant and shared apps or only in the shared apps?
I have the same question. I am running into an error when I want to migrate_schemas saying my users_user relationship doesn't exist.
Its pretty clever, please continue your videos
Thanks, Tom for sharing this tutorial.
I am looking for a solution to use URL parameters instead of subdomains. Eg:
tenant app 1 - 127.0.0.1:8000/tenant/1/.....
tenant app 2 - 127.0.0.1:8000/tenant/2/.....
can you please help me?
You need to use the latest version of django tenants and you will find a example project
Was you able to make it work the way you wanted?
@@tomspythonanddjango6269 Thank you. I am unable to make make the subdomains work on Heroku. I am not very deep in this area. I have built an awesome API with Django-Tenants/Django rest_framework and I have also added Django channels. After some sweats, I have it on Heroku and I can access the public domain. But I am not able to access any tenant-specific domain like famv.my-app.herokuapp.com (I don't pay yet for more dynos). Can you please share an idea with me to make the subdomains work?
Thank you for your help.
@@tomspythonanddjango6269 I make it work wow. I have learned so much by deploying an api powered by Django/Django-tenants/Django-channels and make it work I feel like making a video tutorial about the process. hahah that was cool
@@poormancodespmc4598 Hey brother, I am trying to create a multi tenant application but not able to access the apis by the other computer on the same network. Please help if you know anything about this.
If you are watching this in 2021 and you see the error while migrating, Please Downgrade your Django Version to 3.0.11
Thanks for this! So helpful! Can you share what your hosts file on your mac looks like? what is the format i should use to add the subdomains?
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 www.dtdemo.local
127.0.0.1 t1.dtdemo.local
127.0.0.1 t2.dtdemo.local
127.0.0.1 t3.dtdemo.local
127.0.0.1 t4.dtdemo.local
@@tomspythonanddjango6269 Many thanks!! I was writing it backwards
How I can do it on Windows? Please. Thank You.
@@joshequichi Find host file at 'C:\Windows\System32\drivers\etc', copy it to the desk and edit there, then replace the last file for original file
@@juanbetancourt5106 so much thanks!
how to add different logos for different tenants please ?
This a wonderful video. It worked like a charm. Thank you very much. Would you please make a video on how to add users to be linked from person to Django User as OneToOne relationship. Thanks again.
Thanks for this great tutorial. Have a question, I developed my project based on this tutorial. I need to integrate celery so as to send reminders weekly or daily to each tenant. E.g If a tenant has a ToDo due tomorrow, the specific tenant gets the notification and the others don't. Any material I can use for such? Thanks in advance.
Hello Tom's
Is it possible to implement this solution for a rest application? Using the django-rest-framework framework
Thank you!
I am using it with djangoresframework. It works great.
@@poormancodespmc4598 Do you mind sharing
@@victorisaac8331 unfortunstely not, sorry bro. Let me know how I can't help you integrate them.
Hello, is it possible to have common user table for one or more tenants ...like user table in a seperate schema like in public schema maybe ?
Thanks you very much Tom , really Great work
Tq, I have doubt. How can we use json data for tenants instead of tenant model which is declared in settings (TENANT_MODEL)
You can't do that
@@thomasturner2279 Thank you so much for your reply. I've asked this to many of the people but you have only replied. I like to have contact with you for learning django. Shall i contact you through mail or skype. Kindly reply for this post also. If you are ok i'll give my skype id to you. Once again thanks for ur support.
Hi could you explain why in your case you left out the TenantAdminMixin when registering in admin as the docs include it: class ClientAdmin(TenantAdminMixin, admin.ModelAdmin). I followed your example and everything works fine but I realised I get errors if I include this TenantAdminMixin on trying to add Persons to any tenants. Is there any issues with leaving the mixin out?
Hi Tom. Thank you for the great package Django-tenants. I am implementing a project with it, a saas app. The challenge I am facing now is to give the clients the possibility to add their own apps. What I mean, I could allow the client X to add an app "Finance management", but when I will append the new app in the Tenants apps list, it will be available for all the other clients, not just the client X. That behavior would be annoying for the other clients who are not necessarily interested in it. Is there a way to do that with Django-tenants now? Just like Salesforce does, give the opportunity to add app/objects/tabs and so on for a specific client. I can create the logic for that the only concern is how to display the app only for the client who created it not all the clients. I hope the question is clear and you will find a moment to help me. Greetings from Haiti!
Not sure. I personal just unlock parts of my app with a table of add ons. However every tenant still gets all the database tables even if they don't need them. I hope this helps
Good One Tom. If you can extend this app with user login/multi dashboard you will rock the CZcams. Quality content related to SaaS don't exist for django on CZcams.com.
I am planning to add more CZcams videos
That was pretty clear.
awesome work, thanks!
You used set for INSTALLED_APPS but set is unordered and order matters in case of INSTALLED_APPS.
Hi Tom! I can't serve my app on Apache using mod_wsgi daemon mode.
It works running at runserver mode test. The Apache configuration in the docs didn't work for me.
Do you have any help?
Thanks for the video!
How can i have an auth user that will be responsible for creating Clients (tenants) dynamically ?
thank you!! was perfect :D
This is very timely indeed! I'm trying to get django tenants up with allauth and boy, I have sooooo many questions!
For instance, in the docs, the auth and session apps are only in the SHARED_APPS, but here they show also in TENANT_APPS as well. What is the consequence/reason of doing this?
Fernando Cordeiro the tenant_apps are the ones for the tenants only
@@tomspythonanddjango6269 Yes, that I got... it's the behavior of the apps appearing twice that confuse me. Like auth, for instance: does it mean I can have users that are global across all tenants and users that are tenant-specific?
Fernando Cordeiro yes and no to the users in the public. The problem is if you go both is that users will have the same is as the tenant users gets. Personally I would have the users only in the tenant. There is a project called django tenant users which is worth looking at I don’t use it however I know lots do.
@@tomspythonanddjango6269 The same 'is'? :P
Fernando Cordeiro for django tenant to work django and python are the same as if you didn’t use django tenants
Thank you!
thanks tom
I did the same. Everything is ok. server is running without any error. but my page is not opening. Request Method: GET
Request URL: 127.0.0.1:8000/
No tenant for hostname "127.0.0.1"
These errors are showing
You need to use a host name not 127.0.0.1
Thanks a lot. You are my teacher. I learnt a lot from your videos and posts
Please can you guide me how to create a tenant from web page rather then using create_tenant from command line
@zahid have you had success with this? I am trying to figure out the same thing
@@jaredtangir7784 no I could not
Just add a CreateView? Or a function based view and overtide the form_valid(). Then just create the objects that way. The tenant shema gets created when you call the save method.
Hallo Tom thanks to you i could implement multitenancy in django, but how to get my frontend (vue.js) to understand the tenant domains? in other word how to enable the frondend to serve all the other domains? any idea or a reference page that could help? thanks a lot!
Hi Mannar, I am doing the same using vue as my frontend and django-tenants as backend with postgres, working with some api, kind of not able to completely figure out the steps. if you wish, we can collaborate - gs_amin_iut@yahoo.com
@@amintalukder8583 Hello Amin, i figured it out, in my Vue Frontend there is something called base url, there i can inject the domain: t1.my-domain.com. Thanks :)
i figured it out, in my Vue Frontend there is something called base url, there i can inject the domain: t1.my-domain.com. Thanks :)
@@amintalukder8583 , i was also trying out django tenants with DRF to create Apis and you please help me in this case ?
@@piyushraj186 yes please let me know how can I help you.
It's possible to add 2 different subdomain for same tenant
Yes That is what the domain model is for
@@thomasturner2279 but sir I can't get any logic for this please give me suggestions how to this and thanks for your response 😊
@Tom, have you a LinkedIn profile ?
I have question about auth.user user model, where should i put them in shared apps or tenant apps ??
both , it still works
Thanks for reply.
So for a tenant, user will exist in both tenant and public schema ??
@@piyushraj186 Yes,
Personal in my app I have them in both apps.
Is this approach scalable ? If limited , any advice for tenant limit ? Thanks
As far as I know there are no limits. However it does depend on your computer hardware.
Thanks @@thomasturner2279 Here it is claimed that your approach is not scalable. Am I missing something ? czcams.com/video/RKSwjaZKXL0/video.html
Is it really just only the shared table architecture scalable?
@@erdem.demirci I will watch it later however from what I see he is wrong. The problem with shared architecture is that you have to put a ID of some kind in a lot of tables and there is more chance of data being seen by another client. Years ago I have designed systems like this and it was a nightmare! With tenants you isolate the data of each customer and is easier to manage.
@@thomasturner2279 For now, scalability is more important than isolation, so my concern is whether your approach is scalable. Is "Django-tenants" suitable for scaling?
Meanwhile, we look forward your video series to learn more . Thanks
@@erdem.demirci Yes it is scalable
Thank you for your tutorial ! It really helped me, but I'm having trouble to access my server. My domain's name is: test.local. When I type test.local:8000 on the browser. I'm using swagger api to document my API. Can you please help me?
you either got to change the host file. Or you anything at localhost ie demo.localhost
@@thomasturner2279 thank you very much ! Yesterday I saw one of your answers here showing how was your host file and I managed to do mine here. Can you please tell me, how can I redirect the tenant to its host after user registration? I’m getting the error like the tenant wasn’t created (but it was, I checked at database) and the page is not redirected. Appreciate any help
waesome!!
Hi Tom,
Thanks Tom for this tutorial,
While launching my application using below hosts after creating schema , my server is up but the page is not loading.
t1.postgres.local:8000
t2.postgres.local:8000
Could you please help me to resolve this?
You may need to edit the `/etc/hosts` file on your computer so that `t1.postgres.local` and `t2.postgres.local` are redirected to localhost.
(Also note that when editing the `/etc/hosts` file, you may need to do so with `sudo`, as it may be protected.)
For example, here's what my `/etc/hosts` looks like. I followed Tom's tutorial and set up the domain for t1 and t2 to be `t1.myapp.local` and `t2.myapp.local`.
127.0.0.1 localhost
127.0.0.1 t1.myapp.local
127.0.0.1 t2.myapp.local
I hope this helps!
Where is person.html located?
Your settings file should say where your templates go.
You can put person.html in a folder called `templates` that is inside of `myclientapp`. Make sure to include an empty file called `__init__.py` inside of `templates` so that django can discover it.
So, to summarize: your file structure will look something like this:
myclientapp/
`--> templates/
`------> __init__.py
`------> person.html
Hope this helps!
Can my tenant use their custom domain xyz.com instead of my own subdomain like tenant.mydomain.com
Did you manage to sort?
Yes I did ... Do you need help of any sort?
@@AjibolaLDonjibson Yes, was wondering how you managed to do it! :D Something i'm looking at doing myself as i'm building an web app with django-tenants :) Thanks for getting back me!
@@JoshDavies89 kindly contact me privately. i will explain in details
@@AjibolaLDonjibson i've dropped a comment on your YT page. Howeever, not sure the best to contact you?
Good tutorial, but this doesn't explain that you need to download Postgresql separately when switching from sqlite3.
Please give me ans I am still waiting for your response
I already have :)
Can you share your code for multiple domains for one schema?
@@nabeelahmed2574 There is no code Just add the extra domain in the domain table under Django admin
@@thomasturner2279 ok sir I will try thanks for replyi😊😊
@@thomasturner2279sir Do not understand how it will be, please can you help me?