diff --git a/taggit/managers.py b/taggit/managers.py index 023bf876..0ff8e976 100644 --- a/taggit/managers.py +++ b/taggit/managers.py @@ -255,10 +255,9 @@ def _to_tag_model_instances(self, tags, tag_kwargs): seen_tags = set() for t in tags: if isinstance(t, self.through.tag_model()): - if t in seen_tags: - continue - seen_tags.add(t) - result.append(t) + if t not in seen_tags: + seen_tags.add(t) + result.append(t) elif isinstance(t, str): # we are using a string, so either the tag exists (and we have the lookup) # or we need to create the value @@ -278,11 +277,9 @@ def _to_tag_model_instances(self, tags, tag_kwargs): # confirm if we've seen it or not (this is where case insensitivity comes # into play) - if existing_tag in seen_tags: - continue - - seen_tags.add(existing_tag) - result.append(existing_tag) + if existing_tag not in seen_tags: + seen_tags.add(existing_tag) + result.append(existing_tag) else: raise ValueError( "Cannot add {} ({}). Expected {} or str.".format(