Z
Z
zigen2015-12-10 15:49:16
Django
zigen, 2015-12-10 15:49:16

django-haystack doesn't support 1.9 django?

Good afternoon. Decided to try full-text search. I did everything according to the haystack instructions. I use 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())

When executing a search query, it throws the following error:
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'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
asd111, 2015-12-11
@asd111

they have written on github that work is in progress
https://github.com/django-haystack/django-haystack...

S
skorpix, 2016-02-24
@skorpix

When I upgraded to django 1.9, I also ran into a problem that there are search results, but the object is not available, fell off with the error Model could not be found for SearchResult.
This case, it seems to me, is very similar to mine. I solved my problem like this.
Uninstalled haystack first: pip uninstall django-haystack
Then installed it using a commit that was not in the 2.4.1 branch
-e git://github.com/django-haystack/[email protected]#egg=haystack

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question