Добрый день. Решил попробовать полнотекстовый поиск. Сделал всё по инструкции haystack. Использую whoosh.
class NewsIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
title = indexes.CharField(model_attr='title')
article = indexes.CharField(model_attr='artcile')
def get_model(self):
return News
def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())
При выполнение поискового запроса вываливает следующую ошибку:
Traceback:
File "C:\Python 3.5\lib\site-packages\haystack\query.py" in post_process_results
213. index = ui.get_index(model)
File "C:\Python 3.5\lib\site-packages\haystack\utils\loading.py" in get_index
308. raise NotHandled('The model %s is not registered' % model_klass)
During handling of the above exception (The model None is not registered), another exception occurred:
File "C:\Python 3.5\lib\site-packages\django\core\handlers\base.py" in get_response
149. response = self.process_exception_by_middleware(e, request)
File "C:\Python 3.5\lib\site-packages\django\core\handlers\base.py" in get_response
147. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Python 3.5\lib\site-packages\haystack\views.py" in __call__
53. return self.create_response()
File "C:\Python 3.5\lib\site-packages\haystack\views.py" in create_response
133. (paginator, page) = self.build_page()
File "C:\Python 3.5\lib\site-packages\haystack\views.py" in build_page
110. self.results[start_offset:start_offset + self.results_per_page]
File "C:\Python 3.5\lib\site-packages\haystack\query.py" in __getitem__
272. self._fill_cache(start, bound)
File "C:\Python 3.5\lib\site-packages\haystack\query.py" in _fill_cache
191. to_cache = self.post_process_results(results)
File "C:\Python 3.5\lib\site-packages\haystack\query.py" in post_process_results
219. loaded_objects[model] = model._default_manager.in_bulk(models_pks[model])
Exception Type: AttributeError at /search/
Exception Value: 'NoneType' object has no attribute '_default_manager'