I am trying to use Haystack and Whoosh with my Django app. I followed the steps on Haystack docs, but i am getting this error when i do a search
AttributeError at /search/
'module' object has no attribute 'get_model'
search_indexes.py -
import datetime
from haystack import indexes
from movies.models import Movieclass MovieIndex(indexes.SearchIndex, indexes.Indexable):text = indexes.CharField(document=True, use_template=True)title = indexes.CharField(model_attr='title')def get_model(self):return Moviedef index_queryset(self, using=None):"""Used when the entire index for model is updated."""return self.get_model().objects.all()
I couldn't find help on this error anywhere, what am i doing wrong?
Stacktrace -
Environment:Request Method: GET
Request URL: http://127.0.0.1:8000/search/?q=The+Revenant&models=movies.movieDjango Version: 1.9.1
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','whoosh','haystack','registration','crispy_forms','movies','mptt')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.auth.middleware.SessionAuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware','django.middleware.security.SecurityMiddleware')Traceback:File "/home/dr_sherlock/movienalyse/virmovienalyse/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response149. response = self.process_exception_by_middleware(e, request)File "/home/dr_sherlock/movienalyse/virmovienalyse/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response147. response = wrapped_callback(request, *callback_args, **callback_kwargs)File "/home/dr_sherlock/movienalyse/virmovienalyse/local/lib/python2.7/site-packages/haystack/views.py" in __call__51. self.results = self.get_results()File "/home/dr_sherlock/movienalyse/virmovienalyse/local/lib/python2.7/site-packages/haystack/views.py" in get_results91. return self.form.search()File "/home/dr_sherlock/movienalyse/virmovienalyse/local/lib/python2.7/site-packages/haystack/forms.py" in search116. return sqs.models(*self.get_models())File "/home/dr_sherlock/movienalyse/virmovienalyse/local/lib/python2.7/site-packages/haystack/forms.py" in get_models110. search_models.append(models.get_model(*model.split('.')))Exception Type: AttributeError at /search/
Exception Value: 'module' object has no attribute 'get_model'
Python 2.7.6
Django 1.9.1
Haystack 2.4.1
Whoosh 2.7.0