django-multitenant

Python/Django support for distributed multi-tenant databases like Postgres+Citus

MIT License

Downloads
25.9K
Stars
733
Committers
23
django-multitenant - v4.0.0 Latest Release

Published by gurkanindibay about 1 year ago

What's Changed

New Contributors

Full Changelog: https://github.com/citusdata/django-multitenant/compare/v3.2.1...v4.0.0

django-multitenant - v3.2.1

Published by gurkanindibay over 1 year ago

  • Add m2m with no through_defaults fix (#170)
django-multitenant - v3.2.0

Published by gurkanindibay over 1 year ago

  • Adds DjangoRestFramework support (#157)

  • Adds guidelines to get model in migration (#167)

django-multitenant - v3.1.1

Published by gurkanindibay over 1 year ago

Fixes #164 ManyToMany Non tenant model save issue

django-multitenant - Django 4.1 support and more

Published by gurkanindibay over 1 year ago

  • Adds support for Django 4.1

  • Adds support for setting tenant automatically for ManyToMany related model

  • Fixes invalid error message problem in case of invalid field name

  • Adds support for getting models using apps.get_model

  • Removes reserved tenant_id limitation by introducing TenantMeta usage

  • Introduces ReadTheDocs documentation

django-multitenant - Django 4.0 support

Published by JelteF almost 3 years ago

This release adds Django 4.0 support.

It also drops support for the following EOLed Django and Python versions:

  1. Python 2.7
  2. Django 1.11
  3. Django 3.1
django-multitenant - Fix several bugs and add backwards Distribute migration

Published by JelteF almost 3 years ago

Features

  • Backwards migration for Distribute migration using undistribute_table()
  • Add tests for Django 3.2 and Python 3.9

Fixes

  • Fix migrations on Django 3.0+
  • Fix aggregations using annotate
django-multitenant - Fix migration when model dropped

Published by louiseGrandjonc over 5 years ago

Fix the process of running old migrations when the model has been deleted from the code.

django-multitenant - Add tests on subquery joins

Published by louiseGrandjonc over 5 years ago

Add tests to confirm the join condition in subqueries includes tenant column.

Add tests for django 2.2

django-multitenant - Fix create with current tenant

Published by louiseGrandjonc over 5 years ago

In version 2.0.6, a bug was introduced when doing

set_current_tenant(my_tenant)
MyModel.objects.create(name='test')

the tenant column wasn't filled. This fixes the issue

django-multitenant - Recursive loop fix

Published by louiseGrandjonc over 5 years ago

Fix recursive loop in warning for fields when joining without current_tenant set

django-multitenant - Add the possibility to custom Queryset

Published by louiseGrandjonc over 5 years ago

  • Users can now have their own queryset_class in TenantManager

Here is an example of the usecase

class TaskQueryset(models.QuerySet):
    def opened(self):
        return self.filter(opened=True)

    def closed(self):
        return self.filter(opened=False)

class TaskManager(TenantManagerMixin, models.Manager):
    _queryset_class = TaskQueryset

    def opened(self):
        return self.get_queryset().opened()

    def closed(self):
        return self.get_queryset().closed()


class Task(TenantModelMixin, models.Model):
    name = models.CharField(max_length=255)
    project = TenantForeignKey(Project, on_delete=models.CASCADE,
                               related_name='tasks')
    account = models.ForeignKey(Account, on_delete=models.CASCADE)
    opened = models.BooleanField(default=True)

    objects = TaskManager()

    tenant_id = 'account_id'

  • Clean the delete code to ensure deleting rows only related to current tenant
django-multitenant - Set multi current tenants

Published by louiseGrandjonc over 5 years ago

In this version is introduced the concept of having multiple tenants as the current one making it possible to do

set_current_tenant([tenant_1, tenant_2])

It will add to the filter tenant_id__in=current_tenant instead of tenant_id=current_tenant

django-multitenant - v1.1

Published by saicitus over 6 years ago

  1. Add TenantForeignKey to emulate composite foreign keys between tenant related models.
  2. Split apart library into multiple files. Importing the utility function get_current_tenant would cause errors due to the import statement triggering evaluation of the TenantModel class. This would cause problems if TenantModel were evaluated before the database backend was initialized.
  3. Added a simple TenantOneToOneField which does not try to enforce a uniqueness constraint on the ID column, but preserves all the relationship semantics of using a traditional OneToOneField in Django.
  4. Overrode Django's DatabaseSchemaEditor to produce foreign key constraints on composite foreign keys consisting of both the ID and tenant ID columns for any foreign key between TenantModels
  5. Monkey-patched Django's DeleteQuery implementation to include tenant_id in its SQL queries.
django-multitenant - v1.0.1

Published by saicitus almost 7 years ago

Some bug fixes.