0
保存查詢時,我要保存用戶輸入在我看來,我不知道怎麼做了重新定義搜索查看所以我這樣做:Django的草垛問題會議
request.session['q']=request.GET.get('q')
from haystack.views import SearchView
search_view = SearchView(template = template_name)
return search_view(request)
,但我得到了這個錯誤:
Traceback (most recent call last):
File "/home/usu/mysites/gondor/local/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 280, in run
self.result = application(self.environ, self.start_response)
File "/home/usu/mysites/gondor/local/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 674, in __call__
return self.application(environ, start_response)
File "/home/usu/mysites/gondor/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 245, in __call__
response = middleware_method(request, response)
File "/home/usu/mysites/gondor/local/lib/python2.7/site-packages/django/contrib/sessions/middleware.py", line 36, in process_response
request.session.save()
File "/home/usu/mysites/gondor/local/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py", line 57, in save
session_data = self.encode(self._get_session(no_load=must_create)),
File "/home/usu/mysites/gondor/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py", line 88, in encode
pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL)
File "/usr/local/lib/python2.7/dist-packages/haystack/models.py", line 175, in __getstate__ del(ret_dict['searchsite'])
KeyError: 'searchsite'
如果我刪除行:
request.session['q']=request.GET.get('q')
搜索工作正常,我不知道是否有與草垛問題或者我做錯了什麼。 謝謝。
你試過馴服了嗎? (帶Haystack的KeyErrors的標準問題) – agf
是的,沒有工作。謝謝 – andrebola