# Path: shared_schema_tenants/mixins.py
# class SingleTenantModelMixin(models.Model):
#     tenant = models.ForeignKey(
#         'shared_schema_tenants.Tenant', default=get_default_tenant)
# 
#     objects = SingleTenantModelManager()
# 
#     original_manager = models.Manager()
#     tenant_objects = SingleTenantModelManager()
# 
#     class Meta:
#         abstract = True
#         default_manager_name = 'objects'
#         base_manager_name = 'objects'
# 
#     def save(self, *args, **kwargs):
#         if not hasattr(self, 'tenant'):
#             self.tenant = get_current_tenant()
# 
#         if getattr(self, 'tenant', False):
#             return super(SingleTenantModelMixin, self).save(*args, **kwargs)
#         else:
#             raise TenantNotFoundError()
# 
# class MultipleTenantsModelMixin(models.Model):
#     tenants = models.ManyToManyField('shared_schema_tenants.Tenant')
# 
#     objects = MultipleTenantModelManager()
# 
#     tenant_objects = MultipleTenantModelManager()
#     original_manager = models.Manager()
# 
#     class Meta:
#         abstract = True
#         default_manager_name = 'objects'
#         base_manager_name = 'objects'
# 
#     def save(self, *args, **kwargs):
#         tenant = get_current_tenant()
# 
#         if tenant:
#             instance = super(MultipleTenantsModelMixin, self).save(*args, **kwargs)
#             self.tenants.add(tenant)
#             return instance
#         else:
#             raise TenantNotFoundError()


from django.db import models
from django.conf import settings
from shared_schema_tenants.mixins import (
    SingleTenantModelMixin, MultipleTenantsModelMixin)


class Article(SingleTenantModelMixin):
    title = models.CharField(max_length=100)
    text = models.TextField()
    tags = models.ManyToManyField('Tag')
    author = models.ForeignKey(settings.AUTH_USER_MODEL)

    def __str__(self):
        return '%s - %s' % (self.title, str(self.author))


class Tag(MultipleTenantsModelMixin):
    text = models.CharField(max_length=100)


# Path: shared_schema_tenants/mixins.py
# class SingleTenantModelMixin(models.Model):
#     tenant = models.ForeignKey(
#         'shared_schema_tenants.Tenant', default=get_default_tenant)
# 
#     objects = SingleTenantModelManager()
# 
#     original_manager = models.Manager()
#     tenant_objects = SingleTenantModelManager()
# 
#     class Meta:
#         abstract = True
#         default_manager_name = 'objects'
#         base_manager_name = 'objects'
# 
#     def save(self, *args, **kwargs):
#         if not hasattr(self, 'tenant'):
#             self.tenant = get_current_tenant()
# 
#         if getattr(self, 'tenant', False):
#             return super(SingleTenantModelMixin, self).save(*args, **kwargs)
#         else:
#             raise TenantNotFoundError()
# 
# class MultipleTenantsModelMixin(models.Model):
#     tenants = models.ManyToManyField('shared_schema_tenants.Tenant')
# 
#     objects = MultipleTenantModelManager()
# 
#     tenant_objects = MultipleTenantModelManager()
#     original_manager = models.Manager()
# 
#     class Meta:
#         abstract = True
#         default_manager_name = 'objects'
#         base_manager_name = 'objects'
# 
#     def save(self, *args, **kwargs):
#         tenant = get_current_tenant()
# 
#         if tenant:
#             instance = super(MultipleTenantsModelMixin, self).save(*args, **kwargs)
#             self.tenants.add(tenant)
#             return instance
#         else:
#             raise TenantNotFoundError()


# Path: exampleproject/articles/models.py
from django.db import models
from django.conf import settings
from shared_schema_tenants.mixins import (
    SingleTenantModelMixin, MultipleTenantsModelMixin)



class Article(SingleTenantModelMixin):
    title = models.CharField(max_length=100)
    text = models.TextField()
    tags = models.ManyToManyField('Tag')
    author = models.ForeignKey(settings.AUTH_USER_MODEL)

    def __str__(self):
        return '%s - %s' % (self.title, str(self.author))


class Tag(MultipleTenantsModelMixin):
    text = models.CharField(max_length=100)


    def __str__(self):