Skip to content

bulk_create doesn't work with multi-table inheritance #23

@cfytrok

Description

@cfytrok

Replace bulk_create with iteration in atomic transaction in a multi-table inheritance scenario.

if is_multitabel_inheritance(self.model):
      with transaction.atomic():
          for obj in objs:
               obj.save()
          return objs

def is_multitabel_inheritance(cls):
    for parent in cls._meta.get_parent_list():
        if parent._meta.concrete_model is not cls._meta.concrete_model:
            return True
    return False

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions