Bulk create in related objects

1.3k Views Asked by At

I have 2 models in my app -

In models/parent.py I have -

 from django.db import models
 class Parent(models.Model): 
       class Meta:
          db_table = "parent_table"
       start_date = models.DateField()
       end_date = models.DateField()

In models/child.py I have -

from django.db import models
from models.parent import Parent
class Child(models.Model): 
   class Meta:
      db_table = "child_table"
   some_ref = models.ForeignField(Parent)

We can do single insert into child table using the parent table reference as -

self.child_set.create(**args)

Is there a way by which we can do bulk insert into related table, as the normal bulk_create

0

There are 0 best solutions below