mirror of
https://gitlab.crans.org/bde/nk20-scripts
synced 2024-12-26 17:32:23 +00:00
easier way of detecting Multi-table inheritance
This commit is contained in:
parent
19d76876de
commit
f8132d08ae
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user