Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7e9cb15

Browse files
committedSep 19, 2022
Fix bulk create without objects
1 parent 419f270 commit 7e9cb15

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

‎simple_history/utils.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ def bulk_create_with_history(
112112
obj_when_list.append(When(**attributes, then=i))
113113
q = Q(**attributes)
114114
cumulative_filter = (cumulative_filter | q) if cumulative_filter else q
115-
existing_objs_ids = list(
116-
model_manager.filter(cumulative_filter).values_list("pk", flat=True)
115+
existing_objs_ids = (
116+
list(model_manager.filter(cumulative_filter).values_list("pk", flat=True))
117+
if cumulative_filter
118+
else []
117119
)
118120
objs_with_id = model_manager.bulk_create(
119121
objs, batch_size=batch_size, ignore_conflicts=ignore_conflicts

0 commit comments

Comments
 (0)
Please sign in to comment.