django-haystack problem when saving query in session
Question: I want to save the user input in my view, I don't know how to do it redefining
the searchview so I did this:

    
    
      request.session['q']=request.GET.get('q')
      from haystack.views import SearchView
      search_view = SearchView(template = template_name)
      return search_view(request)
    

but I got this error:

    
    
      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'
    

If I remove the line:

    
    
     request.session['q']=request.GET.get('q') 
    

the search works ok, I don't know if there is a problem with haystack or I'm
doing something wrong. Thanks.


Answer: Finally I found the problem. In another view I was saving in the session the
result of a SerchQuerySet, but the problem didn't raised at the time I've put
the content but it raised when I've put other thing in the session. This was
very difficult to find out.

