Closed florianmartens closed 1 year ago
Have you tried the recommendation in #7 ?
Also your tenanted models only require a ForeignKey to the tenant model
class TenantTag(TenantModel):
tenant_id = "tenant_id"
uuid = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4)
**tenant = ForeignKey(Tenant, on_delete=models.CASCADE)**
Hi @florianmartens,
I'm not sure where the issue is. I was wondering what engine you were using in your DATABASES
settings. Did you change it to 'ENGINE': 'django_multitenant.backends.postgresql',
?
@florianmartens are you using the django_multitenant.backends.postgresql setting as @louiseGrandjonc suggested? Do you still have the problem?
This issue does not seem to be a problem. I'm closing right now. If you have further issues, please open the issue and add some details.
Thank you for providing this library for free. I think it is very valuable. I'm struggling to get the library to work for my setup, though.
I created a tenant and a user model, the object I want to filter is a tag model:
In this setup, I've tried to use a normal ForeignKey (as shown in the docs) and a TenantForeignKey (as shown here). Both resulted in the following 2 problems:
1.) Whenever I want to save an instance (via the admin) I receive an error message:
File "/Users/xxxxxxxx/.virtualenvs/hr-djang/lib/python3.7/site-packages/django_multitenant/mixins.py", line 84, in tenant_value return getattr(self, self.tenant_field, None) TypeError: getattr(): attribute name must be string
2.) I can not get the models to be filtered for tenants in any way. Even though the tenants seem correctly set by the middleware and I'm able to get the tenant by invoking
get_current_tenant()
no filtering is applied. Sending an authenticated request from a tenant_1_user shows tags belonging to tenant_1 and tenant_2 as well.I would really appreciate any help! Thanks.