Все тесты с пагинацией
This commit is contained in:
1 parent
9adcfb26bc
commit
1f7bddff4f
3 files changed
+33
-15
No files matched your search
@@ -3,11 +3,16 @@ from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
from .models import *
|
||||
from .serializers import *
|
||||
from .pagination import *
|
||||
|
||||
# Create your views here.
|
||||
|
||||
|
||||
class GetAllTests(APIView):
|
||||
def get(request,self):
|
||||
all_tests = Test.objects.all()
|
||||
return Response(TestSerializer(all_tests, many=True).data )
|
||||
|
||||
def get(self, request):
|
||||
queryset = Test.objects.all()
|
||||
paginator = AllTestsPagination()
|
||||
paginated_queryset = paginator.paginate_queryset(queryset,request)
|
||||
serializer = TestSerializer(paginated_queryset, many=True)
|
||||
return paginator.get_paginated_response(serializer.data)
|
||||
Reference in new issue
Block a user