django-polymorphic
django-polymorphic copied to clipboard
Problems with multiple concrete inheritance
With the following model structure:
class BaseRegular(models.Model):
model_id = AutoField(primary_key=True)
...
class BasePolymorphic(PolymorphicModel):
...
class MyModel(BasePolymorphic, BaseRegular):
...
When trying to delete an instance of MyModel, a DoesNotExist exception is thrown. I've tracked the issue down to this piece of code in PolymorphicModel's init method:
def accessor_function(self):
attr = model._base_objects.get(pk=self.pk)
return attr
When the model is BaseRegular here, self.pk is MyModel instance's pk, but that's not the primary key for BaseRegular model. Do not know if other places in code assume all parents sharing the same pk.