2011-08-17 77 views
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') 

搜索工作正常,我不知道是否有與草垛問題或者我做錯了什麼。 謝謝。

+0

你試過馴服了嗎? (帶Haystack的KeyErrors的標準問題) – agf

+0

是的,沒有工作。謝謝 – andrebola

回答

0

最後我發現了這個問題。在另一種觀點中,我在會話中保存了一個SerchQuerySet的結果,但問題在我提交內容時沒有提出,但當我將其他內容放入會話中時,問題沒有提出。這很難發現。