From 7e9cb1512915b4e676ca017eefe62a3251e0de3e Mon Sep 17 00:00:00 2001 From: Weston Chan Date: Mon, 19 Sep 2022 08:50:03 -0500 Subject: [PATCH] Fix bulk create without objects --- simple_history/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/simple_history/utils.py b/simple_history/utils.py index 6dbc7af00..382214e79 100644 --- a/simple_history/utils.py +++ b/simple_history/utils.py @@ -112,8 +112,10 @@ def bulk_create_with_history( obj_when_list.append(When(**attributes, then=i)) q = Q(**attributes) cumulative_filter = (cumulative_filter | q) if cumulative_filter else q - existing_objs_ids = list( - model_manager.filter(cumulative_filter).values_list("pk", flat=True) + existing_objs_ids = ( + list(model_manager.filter(cumulative_filter).values_list("pk", flat=True)) + if cumulative_filter + else [] ) objs_with_id = model_manager.bulk_create( objs, batch_size=batch_size, ignore_conflicts=ignore_conflicts