Bladeren bron

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.
Matt Westcott 5 jaren geleden
bovenliggende
commit
34c1b4ccbe
5 gewijzigde bestanden met toevoegingen van 8 en 18 verwijderingen
  1. 1 0
      CHANGELOG.txt
  2. 2 0
      docs/releases/2.7.rst
  3. 2 2
      setup.py
  4. 0 13
      wagtail/admin/compare.py
  5. 3 3
      wagtail/search/index.py

+ 1 - 0
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)

+ 2 - 0
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

+ 2 - 2
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",

+ 0 - 13
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
 

+ 3 - 3
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