Is it possible to c...
 
Notifications
Clear all

Is it possible to create advance filtering and custom pagination whilw using APIView and @api_view decorator?

2 Posts
2 Users
0 Reactions
91 Views
0
Topic starter

Hello and Merry Christmas,

Do you have any documentation about how to create advance filtering and custom pagination while using APIView and @api_view decorator?

For example, if I want to create advanced filtering and custom pagination for the following 

@api_view(['GET', 'POST'])
def studentView(request):
    if request.method == 'GET':
        # get all students from the student table
        students = Student.objects.all()
        serializer = StudentSerializer(students, many=True)
        return Response(serializer.data, status=status.HTTP_200_OK)
    elif request.method == 'POST':
        serializer = StudentSerializer(data = request.data)
        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
2 Answers
0

Hi Estiverne Yardley,

For advanced filtering, you can search on Google and YouTube, where you'll find many tutorials on this topic. If I were to suggest a video, it would be this one: https://youtu.be/NDFgTGTI8zg.

You can learn about this from the video. If you have any confusion or need further help, feel free to ask.

 

0
Topic starter

ok thx!

Share: