Skip to content

Commit

Permalink
Prevent failing on old versions of django-taggit without _remove_pref…
Browse files Browse the repository at this point in the history
…etched_objects

Fixes #182
  • Loading branch information
gasman committed Jan 4, 2024
1 parent ed520b6 commit d8ce092
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions modelcluster/contrib/taggit.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def get_queryset(self, extra_filters=None):

@require_instance_manager
def add(self, *tags):
self._remove_prefetched_objects()
if TAGGIT_VERSION >= (3, 1, 0):
self._remove_prefetched_objects()

if TAGGIT_VERSION >= (1, 3, 0):
tag_objs = self._to_tag_model_instances(tags, {})
Expand All @@ -108,7 +109,8 @@ def add(self, *tags):

@require_instance_manager
def remove(self, *tags):
self._remove_prefetched_objects()
if TAGGIT_VERSION >= (3, 1, 0):
self._remove_prefetched_objects()

tagged_item_manager = self.get_tagged_item_manager()
tagged_items = [
Expand All @@ -135,7 +137,8 @@ def set(self, *args, **kwargs):

@require_instance_manager
def clear(self):
self._remove_prefetched_objects()
if TAGGIT_VERSION >= (3, 1, 0):
self._remove_prefetched_objects()
self.get_tagged_item_manager().clear()


Expand Down

0 comments on commit d8ce092

Please sign in to comment.