How to get Django Tenants up and running (old)

Sdílet
Vložit
  • čas přidán 6. 09. 2024
  • 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.

Komentáře • 121

  • @SadaqatullahNoonari
    @SadaqatullahNoonari Před 5 lety +1

    Keep it up.. your voice matches the authority required on teaching. create MOAR

  • @roficakep
    @roficakep Před 5 lety +6

    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

    • @IllevensKO
      @IllevensKO Před 3 lety

      PLEASE FOR THE LUV OV LARD SOMEONE SHOW US HOW TO USE IT WITH DRF

  • @thefamousdjx
    @thefamousdjx Před 4 lety

    Thanks a lot. This complements the docs real well as they are not very straighforward and interactive tutorial just throws errors

  • @after6097
    @after6097 Před 5 lety

    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

  • @eduardolucas391
    @eduardolucas391 Před 5 lety +3

    Thank you! That was brilliant.

  • @IllevensKO
    @IllevensKO Před 3 lety

    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 !

  • @IllevensKO
    @IllevensKO Před 3 lety

    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 >:(

    • @IllevensKO
      @IllevensKO Před 3 lety

      maybe I'm just curvy-handed. Either way thank you for helping others and contributing to open source community.

    • @IllevensKO
      @IllevensKO Před 3 lety

      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?

  • @a-raheemjamaal5564
    @a-raheemjamaal5564 Před 5 lety +1

    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?

    • @egbertschroeder4497
      @egbertschroeder4497 Před 5 lety +1

      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.

  • @juanbetancourt5106
    @juanbetancourt5106 Před 5 lety

    Its pretty clever, please continue your videos

  • @PavithraSuLa
    @PavithraSuLa Před 4 lety +2

    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
      @tomspythonanddjango6269  Před 4 lety +1

      You need to use the latest version of django tenants and you will find a example project

    • @poormancodespmc4598
      @poormancodespmc4598 Před 3 lety

      Was you able to make it work the way you wanted?

    • @poormancodespmc4598
      @poormancodespmc4598 Před 3 lety

      @@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.

    • @poormancodespmc4598
      @poormancodespmc4598 Před 3 lety

      @@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

    • @taabishansari9649
      @taabishansari9649 Před 2 lety

      @@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.

  • @dhwajguptaiitr
    @dhwajguptaiitr Před 3 lety +1

    If you are watching this in 2021 and you see the error while migrating, Please Downgrade your Django Version to 3.0.11

  • @jaredtangir7784
    @jaredtangir7784 Před 5 lety +3

    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?

    • @tomspythonanddjango6269
      @tomspythonanddjango6269  Před 5 lety +2

      ##
      # 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

    • @jaredtangir7784
      @jaredtangir7784 Před 5 lety +1

      @@tomspythonanddjango6269 Many thanks!! I was writing it backwards

    • @joshequichi
      @joshequichi Před 5 lety

      How I can do it on Windows? Please. Thank You.

    • @juanbetancourt5106
      @juanbetancourt5106 Před 5 lety +1

      @@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

    • @joshequichi
      @joshequichi Před 5 lety

      @@juanbetancourt5106 so much thanks!

  • @hunarb.mohammed9189
    @hunarb.mohammed9189 Před 2 lety

    how to add different logos for different tenants please ?

  • @youssefjaber6885
    @youssefjaber6885 Před 5 lety

    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.

  • @WanjohiKibui
    @WanjohiKibui Před 5 lety

    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.

  • @magnaldomelo7005
    @magnaldomelo7005 Před 5 lety +4

    Hello Tom's
    Is it possible to implement this solution for a rest application? Using the django-rest-framework framework
    Thank you!

    • @poormancodespmc4598
      @poormancodespmc4598 Před 4 lety +1

      I am using it with djangoresframework. It works great.

    • @victorisaac8331
      @victorisaac8331 Před 3 lety

      @@poormancodespmc4598 Do you mind sharing

    • @poormancodespmc4598
      @poormancodespmc4598 Před 3 lety

      @@victorisaac8331 unfortunstely not, sorry bro. Let me know how I can't help you integrate them.

  • @janakisasidhar7582
    @janakisasidhar7582 Před 3 lety

    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 ?

  • @dhs1210
    @dhs1210 Před 4 lety

    Thanks you very much Tom , really Great work

  • @stej2248
    @stej2248 Před 3 lety

    Tq, I have doubt. How can we use json data for tenants instead of tenant model which is declared in settings (TENANT_MODEL)

    • @thomasturner2279
      @thomasturner2279 Před 3 lety

      You can't do that

    • @stej2248
      @stej2248 Před 3 lety

      @@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.

  • @thefamousdjx
    @thefamousdjx Před 4 lety

    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?

  • @poormancodespmc4598
    @poormancodespmc4598 Před 4 lety

    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!

    • @thomasturner2279
      @thomasturner2279 Před 4 lety +1

      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

  • @mhashmi3593
    @mhashmi3593 Před 4 lety

    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.

  • @m.yoganrajyogan8797
    @m.yoganrajyogan8797 Před 4 lety

    That was pretty clear.

  • @wombstrat9116
    @wombstrat9116 Před 3 lety

    awesome work, thanks!

  • @apoorva.pandey
    @apoorva.pandey Před 4 lety

    You used set for INSTALLED_APPS but set is unordered and order matters in case of INSTALLED_APPS.

  • @a5si5
    @a5si5 Před 4 lety

    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!

  • @codeclockyt
    @codeclockyt Před 5 lety

    How can i have an auth user that will be responsible for creating Clients (tenants) dynamically ?

  • @angieximenavalerianocarden37

    thank you!! was perfect :D

  • @FernandoCordeiroDr
    @FernandoCordeiroDr Před 5 lety

    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
      @tomspythonanddjango6269  Před 5 lety

      Fernando Cordeiro the tenant_apps are the ones for the tenants only

    • @FernandoCordeiroDr
      @FernandoCordeiroDr Před 5 lety

      @@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?

    • @tomspythonanddjango6269
      @tomspythonanddjango6269  Před 5 lety

      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.

    • @FernandoCordeiroDr
      @FernandoCordeiroDr Před 5 lety

      @@tomspythonanddjango6269 The same 'is'? :P

    • @tomspythonanddjango6269
      @tomspythonanddjango6269  Před 5 lety

      Fernando Cordeiro for django tenant to work django and python are the same as if you didn’t use django tenants

  • @eliere_de_oliviere
    @eliere_de_oliviere Před 3 lety

    Thank you!

  • @apeironsupport5015
    @apeironsupport5015 Před 4 lety

    thanks tom

  • @zahidaliMughal
    @zahidaliMughal Před 5 lety

    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

  • @zahidaliMughal
    @zahidaliMughal Před 5 lety

    Please can you guide me how to create a tenant from web page rather then using create_tenant from command line

    • @jaredtangir7784
      @jaredtangir7784 Před 5 lety

      @zahid have you had success with this? I am trying to figure out the same thing

    • @zahidaliMughal
      @zahidaliMughal Před 5 lety

      @@jaredtangir7784 no I could not

    • @JoshDavies89
      @JoshDavies89 Před 4 lety

      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.

  • @ladyking83
    @ladyking83 Před 4 lety

    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!

    • @amintalukder8583
      @amintalukder8583 Před 4 lety +1

      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

    • @ladyking83
      @ladyking83 Před 4 lety

      @@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 :)

    • @ladyking83
      @ladyking83 Před 4 lety

      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 :)

    • @piyushraj186
      @piyushraj186 Před 4 lety

      @@amintalukder8583 , i was also trying out django tenants with DRF to create Apis and you please help me in this case ?

    • @amintalukder8583
      @amintalukder8583 Před 4 lety +1

      @@piyushraj186 yes please let me know how can I help you.

  • @nabeelahmed2574
    @nabeelahmed2574 Před 4 lety

    It's possible to add 2 different subdomain for same tenant

    • @thomasturner2279
      @thomasturner2279 Před 4 lety

      Yes That is what the domain model is for

    • @nabeelahmed2574
      @nabeelahmed2574 Před 4 lety

      @@thomasturner2279 but sir I can't get any logic for this please give me suggestions how to this and thanks for your response 😊

  • @sionfongokone6488
    @sionfongokone6488 Před 3 lety

    @Tom, have you a LinkedIn profile ?

  • @piyushraj186
    @piyushraj186 Před 4 lety

    I have question about auth.user user model, where should i put them in shared apps or tenant apps ??

  • @erdem.demirci
    @erdem.demirci Před 4 lety

    Is this approach scalable ? If limited , any advice for tenant limit ? Thanks

    • @thomasturner2279
      @thomasturner2279 Před 4 lety

      As far as I know there are no limits. However it does depend on your computer hardware.

    • @erdem.demirci
      @erdem.demirci Před 4 lety

      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?

    • @thomasturner2279
      @thomasturner2279 Před 4 lety

      @@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.

    • @erdem.demirci
      @erdem.demirci Před 4 lety

      @@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

    • @thomasturner2279
      @thomasturner2279 Před 4 lety

      @@erdem.demirci Yes it is scalable

  • @schults64
    @schults64 Před 3 lety

    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
      @thomasturner2279 Před 3 lety +1

      you either got to change the host file. Or you anything at localhost ie demo.localhost

    • @schults64
      @schults64 Před 3 lety

      @@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

  • @ianoliveiradev
    @ianoliveiradev Před 4 lety

    waesome!!

  • @arunpandian2887
    @arunpandian2887 Před 3 lety

    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?

    • @dan_isaza_dev
      @dan_isaza_dev Před 3 lety

      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!

  • @pierregarcia8083
    @pierregarcia8083 Před 4 lety

    Where is person.html located?

    • @thomasturner2279
      @thomasturner2279 Před 4 lety

      Your settings file should say where your templates go.

    • @dan_isaza_dev
      @dan_isaza_dev Před 3 lety

      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
    @AjibolaLDonjibson Před 4 lety

    Can my tenant use their custom domain xyz.com instead of my own subdomain like tenant.mydomain.com

    • @JoshDavies89
      @JoshDavies89 Před 4 lety

      Did you manage to sort?

    • @AjibolaLDonjibson
      @AjibolaLDonjibson Před 4 lety +1

      Yes I did ... Do you need help of any sort?

    • @JoshDavies89
      @JoshDavies89 Před 4 lety

      @@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!

    • @AjibolaLDonjibson
      @AjibolaLDonjibson Před 4 lety +1

      @@JoshDavies89 kindly contact me privately. i will explain in details

    • @JoshDavies89
      @JoshDavies89 Před 4 lety

      @@AjibolaLDonjibson i've dropped a comment on your YT page. Howeever, not sure the best to contact you?

  • @supersayan6318
    @supersayan6318 Před 4 lety

    Good tutorial, but this doesn't explain that you need to download Postgresql separately when switching from sqlite3.

  • @nabeelahmed2574
    @nabeelahmed2574 Před 4 lety

    Please give me ans I am still waiting for your response

    • @thomasturner2279
      @thomasturner2279 Před 4 lety

      I already have :)

    • @nabeelahmed2574
      @nabeelahmed2574 Před 4 lety

      Can you share your code for multiple domains for one schema?

    • @thomasturner2279
      @thomasturner2279 Před 4 lety

      @@nabeelahmed2574 There is no code Just add the extra domain in the domain table under Django admin

    • @nabeelahmed2574
      @nabeelahmed2574 Před 4 lety

      @@thomasturner2279 ok sir I will try thanks for replyi😊😊

    • @nabeelahmed2574
      @nabeelahmed2574 Před 4 lety

      @@thomasturner2279sir Do not understand how it will be, please can you help me?