Skip to content

Commit 62aeb02

Browse files
committed
Fixed a bug where a different style of import could confuse the collection of indexes. Thanks to groovecoder for the report.
1 parent 6a863e4 commit 62aeb02

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

haystack/utils/loading.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ def __init__(self):
139139
self._facet_fieldnames = {}
140140

141141
def collect_indexes(self):
142+
from haystack.indexes import SearchIndex, BasicSearchIndex, ModelSearchIndex
143+
base_classes = [Indexable, SearchIndex, BasicSearchIndex, ModelSearchIndex]
142144
indexes = []
143145

144146
for app in settings.INSTALLED_APPS:
@@ -148,7 +150,7 @@ def collect_indexes(self):
148150
continue
149151

150152
for item_name, item in inspect.getmembers(search_index_module, inspect.isclass):
151-
if item != Indexable and issubclass(item, Indexable):
153+
if not item in base_classes and issubclass(item, Indexable):
152154
# We've got an index. Check if we should be ignoring it.
153155
class_path = "%s.search_indexes.%s" % (app, item_name)
154156

tests/multipleindex/search_indexes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ def get_model(self):
99
return Foo
1010

1111

12+
# Import the old way & make sure things don't explode.
13+
from haystack.indexes import SearchIndex
14+
15+
1216
class BarIndex(indexes.SearchIndex):
1317
text = indexes.CharField(document=True)
1418

0 commit comments

Comments
 (0)