From 5ba593457ccce2306dea27fa57a551bf31eaee94 Mon Sep 17 00:00:00 2001 From: Raphael Gaschignard Date: Sun, 2 Jun 2024 22:12:41 +1000 Subject: [PATCH] Add note to tricky code --- taggit/managers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/taggit/managers.py b/taggit/managers.py index 6e2dac15..023bf876 100644 --- a/taggit/managers.py +++ b/taggit/managers.py @@ -225,6 +225,10 @@ def _to_tag_model_instances(self, tags, tag_kwargs): # tags can be instances of our through models, or strings tag_strs = [tag for tag in tags if isinstance(tag, str)] + # This map from tag names to tags lets us handle deduplication + # without doing extra queries along the way, all while relying on + # data we were going to pull out of the database anyways + # existing_tags_for_str[tag_name] = tag existing_tags_for_str = {} # we are going to first try and lookup existing tags (in a single query) if case_insensitive: