Django Haystack使用Whoosh随机错误

时间:2012-05-22 11:46:34

标签: django django-haystack whoosh

我在我的Ubuntu服务器上使用django-haystackWhoosh并发现某些搜索查询只会引发错误页面,我不知道为什么会这样...

我正在使用以下

Whoosh==2.4.0
django-haystack==1.2.7

我还每小时运行一次python manage.py update_index

示例追溯

Traceback (most recent call last):

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/newrelic-1.2.0.246/newrelic/hooks/framework_django.py", line 430, in __call__
   return self.__wrapped(*args, **kwargs)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/haystack/views.py", line 50, in __call__
   return self.create_response()

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/haystack/views.py", line 145, in create_response
   return render_to_response(self.template, context, context_instance=self.context_class(self.request))

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/shortcuts/__init__.py", line 20, in render_to_response
   return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/loader.py", line 188, in render_to_string
   return t.render(context_instance)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 123, in render
   return self._render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/newrelic-1.2.0.246/newrelic/api/function_trace.py", line 82, in __call__
   return self._nr_next_object(*args, **kwargs)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 117, in _render
   return self.nodelist.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 744, in render
   bits.append(self.render_node(node, context))

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 757, in render_node
   return node.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/loader_tags.py", line 127, in render
   return compiled_parent._render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/newrelic-1.2.0.246/newrelic/api/function_trace.py", line 82, in __call__
   return self._nr_next_object(*args, **kwargs)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 117, in _render
   return self.nodelist.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 744, in render
   bits.append(self.render_node(node, context))

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 757, in render_node
   return node.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/newrelic-1.2.0.246/newrelic/hooks/framework_django.py", line 622, in __call__
   return self.__wrapped(*args, **kwargs)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/loader_tags.py", line 64, in render
   result = block.nodelist.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 744, in render
   bits.append(self.render_node(node, context))

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 757, in render_node
   return node.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/defaulttags.py", line 311, in render
   return self.nodelist_true.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 744, in render
   bits.append(self.render_node(node, context))

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 757, in render_node
   return node.render(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/defaulttags.py", line 227, in render
   nodelist.append(node.render(context))

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 915, in render
   resolved_vars = [var.resolve(context) for var in self.vars_to_resolve]

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 653, in resolve
   value = self._resolve_lookup(context)

 File "/home/fundedbyme/.virtualenvs/fundedbyme/local/lib/python2.7/site-packages/django/template/base.py", line 692, in _resolve_lookup
   raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bit, current)) # missing attribute

VariableDoesNotExist: Failed lookup for key [object] in u'None'


<WSGIRequest
GET:<QueryDict: {u'q': [u'stockholm']}>,

1 个答案:

答案 0 :(得分:0)

您能否在此处查看您的观点和模板代码?如果仅使用一些查询而不是所有查询,则可能是您传递给视图的参数。 这是我用来在我自己的项目中使用Haystack 2.0和Whoosh 2.3.2进行搜索查询的视图代码:

def search(request):
   sqs = SearchQuerySet().filter(content=AutoQuery(request.GET['q']))
return  render_to_response('search.html', {'sqs': sqs,})

这完全正常。我想你应该考虑使用最新版本的Haystack,因为我遇到了很多旧的稳定版本的bug。我建议您偶尔使用“rebuild_index”,以防万一。