How to bulk get_or_create in Django?

Viewed 957

This answer is 10 years old.

Is there a more efficient way for doing the following in 2020 with PostgreSQL?

for item in item_list:
    e, new = Entry.objects.get_or_create(
        field1 = item.field1,
        field2 = item.field2,
    )

The above approach hits the DB continuously.

Django 2.2 released bulk_update and bulk_create but a bulk_get_or_create doesn't seem to exist?

0 Answers
Related