class SidebarSearch(object): def __init__(self, *args, **kwargs): super(SidebarSearch, self).__init__(*args, **kwargs) self.searchform = None def set_searchform(self): if self.searchform: return self.searchform = SearchForm(self.request.GET) if not self.searchform.is_valid(): messages.error(self.request, "Invalid search query.") def get_context_data(self, **kwargs): ret = super(SidebarSearch, self).get_context_data(**kwargs) self.set_searchform() ret.update({ 'section': 'home', 'subsection': 'search', 'searchform': self.searchform, }) return ret
class SidebarSearch(object): section = 'search' def __init__(self, *args, **kwargs): super(SidebarSearch, self).__init__(*args, **kwargs) self.searchform = None def set_searchform(self): if self.searchform: return self.searchform = SearchForm(self.request.GET) if not self.searchform.is_valid(): messages.error(self.request, "Invalid search query.") def get_context_data(self, **kwargs): ret = super(SidebarSearch, self).get_context_data(**kwargs) self.set_searchform() ret.update({ 'subsection': 'search', 'searchform': self.searchform, }) return ret
def set_searchform(self): if self.searchform: return self.searchform = SearchForm(self.request.GET) if not self.searchform.is_valid(): messages.error(self.request, "Invalid search query.")