0

I am using django-tenants and django_tenant_users with the following apps (settings.py):

SHARED_APPS = (

    'django_tenants',
    'django.contrib.contenttypes',
    'tenant_users.permissions', # Defined in both shared apps and tenant apps
    'tenant_users.tenants', # defined only in shared apps

    # everything below here is optional
    ...

    'tenants', # list the app where your tenant model resides in. Must NOT exist in TENANT_APPS
    'apps.users',   # Custom app that contains the new User Model. Must NOT exist in TENANT_APP

    'debug_toolbar',
)

TENANT_APPS = (

    # for django-tenant-users
    'django.contrib.auth', # Defined in both shared apps and tenant apps
    'django.contrib.contenttypes', # Defined in both shared apps and tenant apps
    'tenant_users.permissions', # Defined in both shared apps and tenant apps

    # your tenant-specific apps
    'apps.jobs',
)

And this is my jobs models.py:

class Job(models.Model):
    id=models.UUIDField(primary_key=True,default=uuid.uuid4, editable=False)
    title = models.CharField(_('Title'),max_length=80, blank=True, default="")
    details= models.CharField(_('Details'), max_length=250, blank=True, default="")
    jobarea = models.ForeignKey('JobArea', verbose_name="Job Area", on_delete=models.CASCADE, null=True)

    def __str__(self):
        return self.title

class JobArea(models.Model):
    id=models.UUIDField(primary_key=True,default=uuid.uuid4, editable=False)
    name = models.CharField(_('Title'),max_length=80, blank=True, default="")
    details = models.CharField(_('Details'), max_length=250, blank=True, default="")
    owners = models.ManyToManyField(settings.AUTH_USER_MODEL)

    def __str__(self):
        return self.name

class Urel(models.Model):
    employee = models.OneToOneField(settings.AUTH_USER_MODEL,on_delete=models.CASCADE)
    job = models.ForeignKey('Job', on_delete=models.CASCADE)

When I try to delete a User that is on the public tenant, I get the following error: relation "jobs_jobarea_owners" does not exist

Is there any solution for this problem that is not the inclusion of apps.jobs in the SHARED APPS?

Pedro Silva
  • 113
  • 7

0 Answers0