Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Lorenzo Peña
    @lorinkoz
    Hello, since this project is WIP we can discuss concepts and implementation, as well as incorporating classic features from the original project django-tenants
    Newlife
    @createinnovative
    Great project! I had given up on creating a multi-tenancy app with Django before i found this project. Please keep up the good work
    Lorenzo Peña
    @lorinkoz
    Thanks @createinnovative
    You should also check django-tenants as it's more mature and production ready
    kojo mcroni
    @mcroni
    hi @lorinkoz , thanks for this amazing project, being going through the docs but still cant wrap my head around the whole tenant dictionary part of the project, wish a lil video about how to set it up would help
    Lorenzo Peña
    @lorinkoz
    Hey @mcroni Don't worry, it's quite confusing as the whole schemas thing is nothing but a clever hack.
    I fear you had a number of APPS in one of your tenants, and then you added those apps to other tenants AFTER running the first migrateschema.
    I suggested you to start with a fresh DB and a stable TENANTS dict and see if it makes it sync.
    In any case, let me explain that once any app is in any schema, if you add the app to another schema later, that won't work, because that app is already "migrated" in the other schema, even though the tables never got created.
    If you compare the django_tenants table of each schema, you'll notice all of them have migrations for all APPS despite your tenant config. The hack through which django-pgschemas and django-tenants work is by using a custom database router that DOESN'T create the tables on the schemas that don't need them, but still record the migration as being executed for that schema.
    Lorenzo Peña
    @lorinkoz
    In a quick glance, your TENANTS dict looks well formed. I noticed other issue: you have auth in the public schema and in other two static schemas. This is one of the most tricky parts, as you might end up with wrongly configured authentication. Would very much like to explain this later so you can decide what's your best configuration.
    kojo mcroni
    @mcroni
    thanks for the quick response, i thought the www schema is the entry to my site, lets say raedarr.com and this is where they will click on sign or signup so the auth needed to be here and thanks for the explanation of how the hack works but i dont see any django_tenants table create too in the schemas, all i see the default django tables
    kojo mcroni
    @mcroni
    i just created a new db but i still dont see any django-pgschemas in the two schemas ie www and public the default schema never gets created`
    kojo mcroni
    @mcroni
    because i was following the docs, i never did the traditional python manage.py makemigrations first before doing makemigrateschemas , my custom apps now show in the schemas,
    Lorenzo Peña
    @lorinkoz
    :thumbsup:
    kojo mcroni
    @mcroni
    hi, probably not sure if its because of the server im running my django app on but i feel accessing any of the subdomains is kinda a bit slow
    KPTAC Technologies
    @kptac
    Excellent work .. pgschemas is listed as beta, was looking to use this on a production site .. anything that we should be aware of in particular? Also what about postgis?
    ok nevermind on postgis, found PGSCHEMAS_ORIGINAL_BACKEND in docs
    spend whole day researching on multi-tenants with django .. so far I find pgschemas as a strong contender mainly because of the option of not using subdomains, but folder structure .. dont want to install a wildcard ssl
    KPTAC Technologies
    @kptac
    There were also some enhancements in django-tenants that I'm not sure are there within this package - mainly from v2.2.0 of django-tenants, with admin site features. Not critical, but handy I suppose.
    Lorenzo Peña
    @lorinkoz
    Thanks @kptac, will work on bringing those admin features in.
    thenewguy
    @thenewguy
    What is the status of this project. Do you recommend it over django-tenants?
    Lorenzo Peña
    @lorinkoz
    @thenewguy Not yet. The folder routing is not formally production ready, although we are using it in production. I'd appreciate if you used it in any of your projects and reported back any issues. Thanks.
    Sandeep Kushwaha
    @saileshkush95
    Do we have any plan for implementing global user features, I mean, please visit this url for more details, django-tenants/django-tenants#320
    Sandeep Kushwaha
    @saileshkush95
    It would be awesome if we provide deployment guide using nginx or Apache. Handling this types of scenario https://serverfault.com/questions/996770/using-nginx-to-serve-multi-tenant-app-with-https
    Ion Alberdi
    @yetanotherion

    Hello to all! I'm facing quite an unexpected bug on a db with 2 schemas (public and reference_tenant).
    I was able to reproduce the bug with the following migration script

    from django.db import migrations
    from django.db.migrations import RunPython
    
    create = """
    DROP FUNCTION IF EXISTS reproduce_error();
    CREATE OR REPLACE FUNCTION reproduce_error()
        RETURNS TEXT AS
    $func$
    BEGIN
        RETURN (select version());
    END
    $func$ LANGUAGE plpgsql;
    """
    
    delete = "DROP FUNCTION IF EXISTS reproduce_error();"
    
    
    def forwards_func(_, schema_editor):
        schema_editor.execute(create, params=None)
    
    
    def reverse_func(_, schema_editor):
        schema_editor.execute(delete, params=None)
    
    
    class Migration(migrations.Migration):
        dependencies = [
            ("business", "former_script"),
        ]
    
        operations = [RunPython(forwards_func, reverse_func)]
    # python manage.py migrate business --schema public

    I have the function in the schema public only.

    # python manage.py migrate business --schema reference_tenant

    I have the function in the schema reference_tenant but not anymore
    in the schema public.

    I verified that by removing
    DROP FUNCTION IF EXISTS reproduce_error();
    in the create variable (in the migration script), the behaviour is the expected one. (having reproduce_error in both schemas).

    It seems that when executed in reference_tenant schema the DROP FUNCTION IF EXISTS reproduce_error() deletes the function in the public schema .

    Do you have an idea on why that could happen?

    Hà Hùng
    @phuonghoanglua
    hi there, I have one question: can I migrate from django-tenants to django-pgschemas ?
    Lorenzo Peña
    @lorinkoz
    @saileshkush95 It's possible to do that, but you'd have to put the app that contains your user model in the public schema and control permissions of all users to schemas.
    @yetanotherion Sorry for the late response. Not sure why I'm not getting email digests of gitter .Glad we could work this out in the repo issue.
    @saileshkush95 About providing docs on how to deploy, it might be out of the scope of the documentation of the project, but I'm okay to put that there as an extra if it's helpful for users. Now, I don't have the bandwidth to do this myself, so if you want to contribute with the setup that worked for you, that would be a good starting point. Please feel free to start a discussion in an issue or submit a PR directly if you're all set on the path.
    @phuonghoanglua Technically yes, but there might be some challenges. pgschemas uses a different philosophy for dealing with tenants. Please make sure you understand these before making such an important decision. Also notice that django-tenants is production ready while pgschemas is still beta (working towards a v1 release, though)
    Lorenzo Peña
    @lorinkoz
    @saileshkush95 Perhaps the explanation here is useful https://youtu.be/OfPE7yj1trw
    Sandeep Kushwaha
    @saileshkush95
    @lorinkoz if i put user model in public schema then all users can able to log into all the tenants
    I i think this is not a good idea , we need some mechanism to prevent some user for some tenants, so that they are only available for specific tenant.
    Lorenzo Peña
    @lorinkoz
    @saileshkush95 That's the only way, to place the user model in the public schema and then customize the authentication mechanism so that you're not just checking credentials, but also whether the user has access to the current tenant or not. You have to handle effective tenant association as you would handle the "is_active" field for a user. Even if authentication passes, if they are not active they cannot log in. Likewise, even if authentication passes, if they don't belong (have access to) the tenant they are authenticating against, they cannot log in.
    Lorenzo Peña
    @lorinkoz
    There is another possible solution. You could still place the User model in dynamic tenants, and create a "special" authentication backend so that you also check against another model that is installed in the public schema, where you will store the superadmins. However, I do not recommend installing the official (as configured in settings) User model both in public and in private schemas, because it will be very confusing at some point.
    Surya Bhusal
    @sbhusal123
    Hello i'm having an issue with separating authentication accrosss the tenants. Does this package ensures that auth user data are separated from the public tenants.
    Lorenzo Peña
    @lorinkoz
    @sbhusal123 You have to place the app that contains the user model in your dynamic tenants, and not in the public schema. Alternatively, if you do need cross-tenant users, then you need to place users in the public schema and then control which users have access to which schemas yourself.
    kyrylokaralyus
    @kyrylokaralyus:matrix.org
    [m]
    hey all, I'm relatively a newbie, starting a multitenant project (for CS bachelor finals), and seems like this package is best suited for my needs; I'll have a bunch of questions later on, but for now I wanted to share this discussion with u/vikingvynotking
    (I'm u/illevens), If any of creators/contributors are interested which parts of a package are unintuitive to the new user.
    tl;dr : the thing that docs lack the most is clear explanation of where the public app (tha governs contents of root homepage url) should live and whether it's principal for it to be the same app that governs tenants\domains. For some reason, django-tenants tell you to put tenant app in the public\shared schema which makes the tenant menu appear in the per-tenant admins.
    Lorenzo Peña
    @lorinkoz
    Hi @kyrylokaralyus:matrix.org I have enabled GitHub discussions on the pgschemas repo, feel free to start a debate there (https://github.com/lorinkoz/django-pgschemas/discussions) for this very needed topic. Much appreciated.
    Lorenzo Peña
    @lorinkoz
    Hey folks. With GitHub discussions becoming globally available, I am deprecating this gitter room in favor of discussions. Please create any new debates or Q/As there. Thanks and see you on GH!
    Rohit Hazare
    @rohit2096_gitlab
    Hi.. I am trying to deploy my django application. I have added static tenant to my app. "live": { "APPS": [ "django.contrib.auth", "django.contrib.sessions", "django.contrib.admin", 'django.contrib.messages', "app_name", ], "DOMAINS": ["live.domain.com"], "URLCONF": "app_name.urls", }, This is working with localhost but gives No tenant for hostname '0.0.0.0'
    Page not found error when hosted on server
    Lorenzo Peña
    @lorinkoz
    @rohit2096_gitlab You need to make sure Django is getting a proper domain name for the request, otherwise there is no way for django to know which tenant is being accessed.
    Rohit Hazare
    @rohit2096_gitlab
    I have mentioned the domain name in ALLOWED_HOSTS too. But it just does not recognize it
    Do I have to add the static tenants to the database too?
    Rohit Hazare
    @rohit2096_gitlab
    How can I create superuser here? Getting relation does not exist auth_user error
    Rohit Hazare
    @rohit2096_gitlab
    @lorinkoz please help me out here