TenantModel provides tenant_id attribute to specify the pk field to be used, or at least, the examples points out to specify tenant_id = 'id' to the Store model, which is used as the Tenant model.
But if I try to specify a different pk column to the Tenant model I got several errors because TenantManager and TenantQuerySet refers to current_tenant.id
This should probably be getattr(current_tenant, current_tenant.tenant_id)
#Below is the manager related to the above class.
class TenantManager(TenantQuerySet.as_manager().__class__):
#Injecting tenant_id filters in the get_queryset.
#Injects tenant_id filter on the current model for all the non-join/join queries.
def get_queryset(self):
current_tenant=get_current_tenant()
if current_tenant:
kwargs = { self.model.tenant_id: getattr(current_tenant, current_tenant.tenant_id)}
return super(TenantManager, self).get_queryset().filter(**kwargs)
return super(TenantManager, self).get_queryset()
TenantModel provides tenant_id attribute to specify the pk field to be used, or at least, the examples points out to specify
tenant_id = 'id'
to the Store model, which is used as the Tenant model. But if I try to specify a different pk column to the Tenant model I got several errors because TenantManager and TenantQuerySet refers tocurrent_tenant.id
This should probably be
getattr(current_tenant, current_tenant.tenant_id)