Closed miguelrosalesmtl closed 4 years ago
We fixed it by using this implementation in our model base class:
def save(self, *args, **kwargs):
tenant_value = get_current_tenant_value()
if self._state.adding and tenant_value and not isinstance(tenant_value, list):
setattr(self, self.tenant_field, tenant_value)
return super().save(*args, **kwargs)
my man. :+1:
Hi @miguelrosalesmtl, @s4ke,
thank you for raising this issue. I created a branch with a fix for this: https://github.com/citusdata/django-multitenant/tree/fix-uuid-tenant-set
If you want to try it before we publish the fix on pypi, it would be great.
there's already a release for that?
Hi,
I just released a new version 2.2.1
with the fix for this.
Hi, I tried using uuids as ids and it doesn't work because of the save method in TenantMixin. When saving the setattr(self, self.tenant_field, tenant_value) line never gets called because self.pk has value when dealing with uuids different from IntegerField. I created my own abstract class and added a created field it did the trick, but it would be nice to have native support for uuids.