comparison custom_search/views.py @ 763:20a3bf7a6370

Add username to search query logging.
author Brian Neal <bgneal@gmail.com>
date Sun, 19 Jan 2014 11:25:45 -0600
parents
children 840c1a8bd8af
comparison
equal deleted inserted replaced
762:840f2579ef1c 763:20a3bf7a6370
1 """Custom views for searching."""
2
3 from haystack.views import SearchView
4
5
6 class UserSearchView(SearchView):
7 """This class passes the user making the search as an __init__ argument to
8 the search form as the keyword argument 'user'.
9
10 """
11 def build_form(self, form_kwargs=None):
12 """Pass the request.user object to the form's constructor."""
13 if not form_kwargs:
14 form_kwargs = {}
15 if 'user' not in form_kwargs:
16 form_kwargs['user'] = self.request.user
17 return super(UserSearchView, self).build_form(form_kwargs)