python - django haystack - how to use with current view having some context -


i have view puts context , renders template context. want view display things if no search query there, , show searhed things, if searched.

class mycurrentview(view):      def get(self, request):          data = { 'users': user.objects.all() }          return render_to_response("mytemp.html", ..  urls.py:       url(r'^search/$', mycurrentview.as_view()) 

now, integrating searchview this:

class mycurrentview(searchview):  (if u observe, subclassed searchview).      template = 'mytemp.html'      def get(self, request):          data = { 'users': user.objects.all() }          return render_to_response...       def get_context_data(self, ...):           print "....this should print"  #but not printing. so, unable add data      return data  urls.py:       url(r'^search/$', mycurrentview.as_view())         # as_view() gave me error, did mycurrentview() , may thats y, get_context_data not calling. 

will provide more information if necessary.

new django-style class based views added via pr #1130 django-haystack:

you can use search views django (see changes in pull request).

from haystack.generic_views import searchview  class mysearchview(searchview):      def get_context_data(self, **kwargs):         # whatever want context 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -