easier way of detecting Multi-table inheritance

This commit is contained in:
Pierre-antoine Comby 2020-05-21 18:26:42 +02:00
parent 19d76876de
commit f8132d08ae
1 changed files with 3 additions and 3 deletions

View File

@ -7,8 +7,6 @@ from collections import defaultdict
from django.apps import apps
from django.db import transaction
from django.contrib.auth.models import User
from django.db.models import Model
from polymorphic.models import PolymorphicModel
@ -67,7 +65,9 @@ class BulkCreateManager(object):
def _commit(self, model_class):
model_key = model_class._meta.label
if model_class.__base__ in [Model, PolymorphicModel] or model_class is User:
# check for mutli-table inheritance it happens
# if model_class is a grand-child of PolymorphicModel
if model_class.__base__ is not PolymorphicModel and model_class.__base__.__base__ is PolymorphicModel:
model_class.objects.bulk_create(self._create_queues[model_key])
else:
# ensure that parents models exists