Guest User

Untitled

a guest
Apr 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. REST_FRAMEWORK = {
  2. 'rest_framework.pagination.PageNumberPagination',
  3. 'PAGE_SIZE': 1,
  4. }
  5.  
  6. class example(GenericAPIView):
  7. queryset = example.objects.all()
  8. serializer_class = ExampleSerializer
  9.  
  10. def get(self, request, format=None):
  11. query = request.GET.get('name')
  12. if query:
  13. bla = example.objects.filter(name=query)
  14. else:
  15. bla = example.objects.all()
  16. if bla:
  17. serializer = ExampleSerializer(bla, many=True)
  18. return Response(serializer.data)
  19. else:
  20. return Response(status=status.HTTP_404_NOT_FOUND)
Add Comment
Please, Sign In to add comment