diff --git a/kitsune/wiki/widgets.py b/kitsune/wiki/widgets.py index 3455c520bba..d4d3990df95 100644 --- a/kitsune/wiki/widgets.py +++ b/kitsune/wiki/widgets.py @@ -1,4 +1,3 @@ -import collections from django import forms from django.template.loader import render_to_string @@ -6,6 +5,11 @@ from kitsune.products.models import Topic from kitsune.wiki.models import Document +try: + from collections.abc import Iterable +except ImportError: + from collections import Iterable + class ProductTopicsAndSubtopicsWidget(forms.widgets.SelectMultiple): """A widget to render topics organized by product and with subtopics.""" @@ -35,7 +39,7 @@ def process_topic(self, value, topic): topic.checked = True elif ( not isinstance(value, str) - and isinstance(value, collections.Iterable) + and isinstance(value, Iterable) and topic.id in value ): topic.checked = True @@ -49,7 +53,7 @@ class RelatedDocumentsWidget(forms.widgets.SelectMultiple): def render(self, name, value, attrs=None, renderer=None): if isinstance(value, int): related_documents = Document.objects.filter(id__in=[value]) - elif not isinstance(value, str) and isinstance(value, collections.Iterable): + elif not isinstance(value, str) and isinstance(value, Iterable): related_documents = Document.objects.filter(id__in=value) else: related_documents = Document.objects.none()