Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REST_FRAMEWORK = {
- 'rest_framework.pagination.PageNumberPagination',
- 'PAGE_SIZE': 1,
- }
- class example(GenericAPIView):
- queryset = example.objects.all()
- serializer_class = ExampleSerializer
- def get(self, request, format=None):
- query = request.GET.get('name')
- if query:
- bla = example.objects.filter(name=query)
- else:
- bla = example.objects.all()
- if bla:
- serializer = ExampleSerializer(bla, many=True)
- return Response(serializer.data)
- else:
- return Response(status=status.HTTP_404_NOT_FOUND)
Add Comment
Please, Sign In to add comment