diff --git a/django/core/paginator.py b/django/core/paginator.py index f149598203f0..44e441242176 100644 --- a/django/core/paginator.py +++ b/django/core/paginator.py @@ -121,9 +121,12 @@ def _check_object_list_is_ordered(self): QuerySetPaginator = Paginator # For backwards-compatibility. +try: + from collections.abc import Sequence +except ImportError: + from collections import Sequence - -class Page(collections.Sequence): +class Page(Sequence): def __init__(self, object_list, number, paginator): self.object_list = object_list diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index e51b1037ca30..c4897f4dab98 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -8,7 +8,13 @@ """ import copy import warnings -from collections import Counter, Iterator, Mapping, OrderedDict +from collections import Counter, OrderedDict +try: + from collections.abc import Iterable + from collections.abc import MutableMapping +except ImportError: + from collections import Iterable + from collections import MutableMapping from itertools import chain, count, product from string import ascii_uppercase