|
8 | 8 |
|
9 | 9 | from django.conf import settings
|
10 | 10 | from django.core.exceptions import ImproperlyConfigured
|
11 |
| -from django.utils.datastructures import SortedDict |
12 | 11 | from django.utils.module_loading import module_has_submodule
|
13 | 12 |
|
14 | 13 | from haystack.exceptions import NotHandled, SearchFieldError
|
15 | 14 | from haystack.utils import importlib
|
16 | 15 | from haystack.utils.app_loading import haystack_get_app_modules
|
17 | 16 |
|
18 | 17 |
|
| 18 | +try: |
| 19 | + # Introduced in Python 2.7 |
| 20 | + from collections import OrderedDict |
| 21 | +except ImportError: |
| 22 | + # Deprecated in Django 1.8; removed in Django 1.9 (both of which require |
| 23 | + # at least Python 2.7) |
| 24 | + from django.utils.datastructures import SortedDict as OrderedDict |
| 25 | + |
| 26 | + |
19 | 27 | def import_class(path):
|
20 | 28 | path_bits = path.split('.')
|
21 | 29 | # Cut off the class name at the end.
|
@@ -152,7 +160,7 @@ class UnifiedIndex(object):
|
152 | 160 | # Used to collect all the indexes into a cohesive whole.
|
153 | 161 | def __init__(self, excluded_indexes=None):
|
154 | 162 | self._indexes = {}
|
155 |
| - self.fields = SortedDict() |
| 163 | + self.fields = OrderedDict() |
156 | 164 | self._built = False
|
157 | 165 | self.excluded_indexes = excluded_indexes or []
|
158 | 166 | self.excluded_indexes_ids = {}
|
@@ -192,7 +200,7 @@ def collect_indexes(self):
|
192 | 200 |
|
193 | 201 | def reset(self):
|
194 | 202 | self._indexes = {}
|
195 |
| - self.fields = SortedDict() |
| 203 | + self.fields = OrderedDict() |
196 | 204 | self._built = False
|
197 | 205 | self._fieldnames = {}
|
198 | 206 | self._facet_fieldnames = {}
|
|
0 commit comments