From 05bcf3e204d3c5978f072a01709b612b4365c99c Mon Sep 17 00:00:00 2001 From: GloriaaLi Date: Thu, 10 Mar 2016 11:26:15 -0500 Subject: [PATCH] add filter of source --- api/webview/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/webview/views.py b/api/webview/views.py index bc077f54..d9dcec32 100644 --- a/api/webview/views.py +++ b/api/webview/views.py @@ -28,7 +28,11 @@ def perform_create(self, serializer): def get_queryset(self): """ Return all documents """ - return Document.objects.all() + queryset = Document.objects.all() + source_from_query = self.request.query_params.get('source', None) + if source_from_query is not None: + queryset = queryset.filter(source=source_from_query) + return queryset class DocumentsFromSource(generics.ListAPIView):