From 0e60316596df97cade1fc72657c5dfcdfeee9370 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Thu, 13 Sep 2018 12:55:34 +0200 Subject: [PATCH 1/1] fix weird bug (race condition?) --- src/newtagging/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/newtagging/models.py b/src/newtagging/models.py index 9d12111d2..e42295d70 100644 --- a/src/newtagging/models.py +++ b/src/newtagging/models.py @@ -64,7 +64,7 @@ class TagManager(models.Manager): # Add new tags tags_to_add = [tag for tag in updated_tags if tag not in current_tags] for tag in tags_to_add: - self.intermediary_table_model.objects.create(tag=tag, content_object=obj) + self.intermediary_table_model.objects.get_or_create(tag=tag, content_object=obj) tags_updated.send(sender=type(obj), instance=obj, affected_tags=tags_to_add + tags_for_removal) -- 2.20.1