From 34c1b4ccbe4a143492ae534e95bf61a160104a9f Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Tue, 6 Aug 2019 20:28:12 +0100 Subject: [PATCH] Upgrade django-taggit to 1.x django-taggit 1.x drops Python 2.x support and thus the dependency on django.utils.six; this is a prerequisite for supporting Django 3.0. The signature of TaggableManager.value_from_object has changed to return a list of Tags (previously it was a QuerySet of TaggedItems) and so search indexing and comparison need to be updated accordingly. There is a corresponding fix to ClusterTaggableManager in django-modelcluster 5.0. --- CHANGELOG.txt | 1 + docs/releases/2.7.rst | 2 ++ setup.py | 4 ++-- wagtail/admin/compare.py | 13 ------------- wagtail/search/index.py | 6 +++--- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 74ea4a34b..bb265346d 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -10,6 +10,7 @@ Changelog * Move and refactor upgrade notification JS (Jonny Scholes) * Add ability to insert internal anchor links/links with fragment identifiers in Draftail (rich text) fields (Iman Syed) * Remove need for Elasticsearch `update_all_types` workaround, upgrade minimum release to 6.4.0 or above (Jonathan Liuti) + * Upgrade django-modelcluster to>=5.0 and upgrade django-taggit to >=1.0 for Django 3.0 support (Matt Westcott) * Fix: Added line breaks to long filenames on multiple image / document uploader (Kevin Howbrook) * Fix: Added https support for Scribd oEmbed provider (Rodrigo) * Fix: Changed StreamField group labels color so labels are visible (Catherine Farman) diff --git a/docs/releases/2.7.rst b/docs/releases/2.7.rst index 0c928407d..5807caf1a 100644 --- a/docs/releases/2.7.rst +++ b/docs/releases/2.7.rst @@ -25,6 +25,8 @@ Other features * Remove need for Elasticsearch ``update_all_types`` workaround, upgrade minimum release to 6.4.0 or above (Jonathan Liuti) * Add ability to insert internal anchor links/links with fragment identifiers in Draftail (rich text) fields (Iman Syed) * Added Table Block caption for accessibility (Rahmi Pruitt) + * Upgrade django-modelcluster to>=5.0 and upgrade django-taggit to >=1.0 for Django 3.0 support (Matt Westcott) + Bug fixes diff --git a/setup.py b/setup.py index c61f40e83..dffe3a840 100755 --- a/setup.py +++ b/setup.py @@ -22,8 +22,8 @@ except ImportError: install_requires = [ "Django>=2.0,<2.3", - "django-modelcluster>=4.2,<5.0", - "django-taggit>=0.23,<1.0", + "django-modelcluster>=5.0,<6.0", + "django-taggit>=1.0,<2.0", "django-treebeard>=4.2.0,<5.0", "djangorestframework>=3.7.4,<4.0", "draftjs_exporter>=2.1.5,<3.0", diff --git a/wagtail/admin/compare.py b/wagtail/admin/compare.py index d5b41421f..d3e56ad9c 100644 --- a/wagtail/admin/compare.py +++ b/wagtail/admin/compare.py @@ -274,19 +274,6 @@ class M2MFieldComparison(FieldComparison): class TagsFieldComparison(M2MFieldComparison): - def get_items(self): - tags_a = [ - tag.tag - for tag in self.val_a - ] - - tags_b = [ - tag.tag - for tag in self.val_b - ] - - return tags_a, tags_b - def get_item_display(self, tag): return tag.slug diff --git a/wagtail/search/index.py b/wagtail/search/index.py index da6836f9a..b879c4ff8 100644 --- a/wagtail/search/index.py +++ b/wagtail/search/index.py @@ -225,9 +225,9 @@ class BaseField: if hasattr(field, 'get_searchable_content'): value = field.get_searchable_content(value) elif isinstance(field, TaggableManager): - # Special case for tags fields. Convert QuerySet of TaggedItems into QuerySet of Tags - Tag = field.remote_field.model - value = Tag.objects.filter(id__in=value.values_list('tag_id', flat=True)) + # As of django-taggit 1.0, value_from_object returns a list of Tag objects, + # which matches what we want + pass elif isinstance(field, RelatedField): # The type of the ForeignKey may have a get_searchable_content method that we should # call. Firstly we need to find the field its referencing but it may be referencing