0

which it is the cause of this error?? I'm using django1.9 and django-haystack == 2.4.1

(venv)daniel@daniel22:~/prototipos/venv/ejemplo/exp$ python manage.py update_index

Indexing 2 documents
/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/haystack/fields.py:137: RemovedInDjango110Warning: render() must be called with a dict, not a Context.
  return t.render(Context({'object': obj}))

ERROR:root:Error updating art using default 
Traceback (most recent call last):
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 188, in handle_label
    self.update_backend(label, using)
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 233, in update_backend
    do_update(backend, index, qs, start, end, total, verbosity=self.verbosity, commit=self.commit)
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 96, in do_update
    backend.update(index, current_qs, commit=commit)
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 193, in update
    bulk(self.conn, prepped_docs, index=self.index_name, doc_type='modelresult')
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/elasticsearch/helpers/__init__.py", line 188, in bulk
    for ok, item in streaming_bulk(client, actions, **kwargs):
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/elasticsearch/helpers/__init__.py", line 160, in streaming_bulk
    for result in _process_bulk_chunk(client, bulk_actions, raise_on_exception, raise_on_error, **kwargs):
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/elasticsearch/helpers/__init__.py", line 132, in _process_bulk_chunk
    raise BulkIndexError('%i document(s) failed to index.' % len(errors), errors)
BulkIndexError: (u'2 document(s) failed to index.', [{u'index': {u'_type': u'modelresult', u'_id': u'art.document.1', u'ok': True, u'_version': 4, u'_index': u'haystack'}}, {u'index': {u'_type': u'modelresult', u'_id': u'art.document.2', u'ok': True, u'_version': 4, u'_index': u'haystack'}}])
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 183, in handle
    return super(Command, self).handle(*items, **options)
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 548, in handle
    label_output = self.handle_label(label, **options)
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 188, in handle_label
    self.update_backend(label, using)
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 233, in update_backend
    do_update(backend, index, qs, start, end, total, verbosity=self.verbosity, commit=self.commit)
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 96, in do_update
    backend.update(index, current_qs, commit=commit)
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 193, in update
    bulk(self.conn, prepped_docs, index=self.index_name, doc_type='modelresult')
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/elasticsearch/helpers/__init__.py", line 188, in bulk
    for ok, item in streaming_bulk(client, actions, **kwargs):
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/elasticsearch/helpers/__init__.py", line 160, in streaming_bulk
    for result in _process_bulk_chunk(client, bulk_actions, raise_on_exception, raise_on_error, **kwargs):
  File "/home/daniel/prototipos/venv/local/lib/python2.7/site-packages/elasticsearch/helpers/__init__.py", line 132, in _process_bulk_chunk
    raise BulkIndexError('%i document(s) failed to index.' % len(errors), errors)
elasticsearch.helpers.BulkIndexError: (u'2 document(s) failed to index.', [{u'index': {u'_type': u'modelresult', u'_id': u'art.document.1', u'ok': True, u'_version': 4, u'_index': u'haystack'}}, {u'index': {u'_type': u'modelresult', u'_id': u'art.document.2', u'ok': True, u'_version': 4, u'_index': u'haystack'}}])

1 Answer 1

0

EDIT: you can use the latest version from github v2.5 which has these changes or make them yourself. Ultimately it comes down to piss poor error handling in the models.py file where they catch an exception without logging and continue on with model=None


It seems haystack 2.4 is not Django 1.9 compatible. I fixed this by deleting the context function and returning the dict only i.e:

in fields.py Line 137

Before:
return t.render(Context({'object': obj}))

After:
return t.render({'object': obj})

To do this you will need to directly edit the source of the site-package - if you are using Virtual Env, and you should be, then just go env/lib/python*.*/site-packages/haystack

Other issues I came across:

in urls.py
After:
    urlpatterns = [
        url(r'^$', SearchView(), name='haystack_search'),
    ]

-

in forms.py Line 110 and in Models.py line 103 and morelikethis.py line 35:

before:
self._model = apps.get_model(self.app_label, self.model_name)

after:
from django.apps import apps
self._model = apps.get_model(self.app_label, self.model_name)
4
  • You must also be careful if you are using Elasticseach >= 2.X, because Haystack is not compatible with it.
    – primoz
    Feb 23, 2016 at 13:30
  • Seems to be functioning after the fixes above.
    – pypypy
    Feb 23, 2016 at 13:39
  • @pypypyI have been trying to figure out why I can't use results.objects.get_absolute_url after your fixes will this work? and I notice you mentioned about being in a virtualenv. will this not work in production?
    – losee
    Mar 21, 2016 at 2:06
  • I think it has to do with not implementing the method that gets called to generate the url. Post the error and I'll take a look
    – pypypy
    Mar 25, 2016 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.