Open pvandegeer opened 6 years ago
If a Tenant model supplies its own PK, for example a UUID, then create_schema() is never called.
The code for TenantMixin check for the availability of the pk to determine if a model is new: https://github.com/bernardopires/django-tenant-schemas/blob/master/tenant_schemas/models.py#L57 This doesn't work if the key is self supplied.
Possible fix: Django >=1.8 supports self._state.adding which returns True if the instance isn't saved yet. See also: https://stackoverflow.com/questions/2037320/what-is-the-canonical-way-to-find-out-if-a-django-model-is-saved-to-db/19379636#19379636
self._state.adding
If a Tenant model supplies its own PK, for example a UUID, then create_schema() is never called.
The code for TenantMixin check for the availability of the pk to determine if a model is new: https://github.com/bernardopires/django-tenant-schemas/blob/master/tenant_schemas/models.py#L57 This doesn't work if the key is self supplied.
Possible fix: Django >=1.8 supports
self._state.adding
which returns True if the instance isn't saved yet. See also: https://stackoverflow.com/questions/2037320/what-is-the-canonical-way-to-find-out-if-a-django-model-is-saved-to-db/19379636#19379636