Created
November 16, 2012 16:33
-
-
Save bennylope/4088760 to your computer and use it in GitHub Desktop.
Simplified filtering without validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyListView(ListView): | |
def get(self, request, *args, **kwargs): | |
self.object_list = self.get_queryset() | |
search_query = request.GET.get('search_query') | |
if search_query: | |
self.object_list = self.object_list.filter(name=search_query) | |
context = self.get_context_data(object_list=self.object_list) | |
return self.render_to_response(context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment