2016-02-12 99 views
0

它是這個錯誤的原因? 我使用django1.9和Django的草垛== 2.4.1python - Haystack + Django 1.9 + Elasticsearch錯誤

(venv)[email protected]:~/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'}}]) 

回答

0

編輯: 可以使用從GitHub V2.5最新版本,其中有這些變化還是讓他們自己。最終它歸結爲小便誤差差models.py文件處理他們捕獲異常沒有日誌記錄,並繼續與模型=無


好像大海撈針2.4不Django的1.9兼容。我解決了這個問題通過刪除上下文功能,只有即返回字典:

in fields.py Line 137 

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

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

要做到這一點,你需要直接編輯站點包的來源 - 如果你正在使用虛擬信封,你應該,然後只是去ENV/lib中/ Python的* * /站點包/草垛

其他問題,我碰到:

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) 
+0

如果您使用Elasticseach> = 2.X,則必須小心,因爲Haystack與它不兼容。 – primoz

+0

似乎在上述修復之後運行。 – pypypy

+0

@pypypyI一直在試圖找出爲什麼我的修復後不能使用results.objects.get_absolute_url這個工作嗎?我注意到你提到過在虛擬世界中。這不會在生產中起作用嗎? – losee