0

Error screenshot

    AttributeError at /search/
    'NoneType' object has no attribute '_default_manager'

    Request Method: GET
    Request URL:    http://127.0.0.1:8000/search/?q=desktop
    Django Version: 1.9
    Exception Type: AttributeError
    Exception Value:'NoneType' object has no attribute '_default_manager'
    Exception Location: /home/ankit/venv/django/lib/python3.4/site-packages/haystack/query.py in post_process_results, line 219
    Python Executable:  /home/ankit/venv/django/bin/python
    Python Version: 3.4.3
    Python Path:    ['/home/ankit/venv/django/p2',
                     '/home/ankit/venv/django/lib/python3.4',
                     '/home/ankit/venv/django/lib/python3.4/plat-x86_64-linux-gnu',
                     '/home/ankit/venv/django/lib/python3.4/lib-dynload',
                     '/usr/lib/python3.4',
                     '/usr/lib/python3.4/plat-x86_64-linux-gnu',
                     '/home/ankit/venv/django/lib/python3.4/site-packages']
    Server time:    Sun, 27 Dec 2015 10:29:28 +0000

My search_indexes.py

import datetime
from haystack import indexes
from inventory.models import Item

class ItemIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
pub_date = indexes.DateTimeField(model_attr='pub_date')

content_auto = indexes.EdgeNgramField(model_attr='title')

def get_model(self):
    return Item

def index_queryset(self, using=None):
    return self.get_model().objects.all()

My settings.py file

HAYSTACK_CONNECTIONS = {
    'default': {
    'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
    'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
    },
}
  • Just started getting this error as well, though I'm using ElasticSearch. Did you recently upgrade Django? – onyeka Dec 28 '15 at 22:15
  • This is being worked on for the newest version but it's not available yet, so I had to override the app for now with https://github.com/barbuza/django-haystack/commit/c4e398319e8ff3e5049011a0078c81821760f78d – onyeka Jan 02 '16 at 15:05

1 Answers1

1

The django.db.model.get_model is not available any longer in 1.9, so None is returned when calling django.db.models.get_model, but in the more recent commit (from the 3rd of January) the utils.app_loading.py is used to either use the django.apps.apps.get_model when using Django 1.7 or higher, otherwise the old django.db.models._get_models is used.

So, best to upgrade to the latest development version git+https://github.com/django-haystack/django-haystack.git.

Jan Willems
  • 171
  • 2
  • 11