Reputation: 23654
Given the url conf:
r'^(?P<some_var>[-a-z0-9\.]*[a-z0-9\.]\.\w+)/search/$'
How do I pass the named group some_var
to Haystack's SearchView?
I'd like to override SearchView.get_results()
to do an additional filter depending on some_var
.
Is this the best way to do it?
Upvotes: 3
Views: 1542
Reputation: 239380
Subclass SearchView
and override __call__
which is the "view" part of the class.
from haystack.views import SearchView
class MySearchView(SearchView):
def __call__(self, request, some_var):
self.some_var = some_var
return super(MySearchView, self).__call__(request)
Then, you can use self.some_var
in other methods on the class.
Upvotes: 6