Django RestFramwrok loop issues it only runs for the firsst element

Django RestFramwrok loop issues it only runs for the firsst element

It supposed run 3 times but it only runs for the first element. I have tried to run it on python console and the same approach works fine. not able to figure out the issue with code.

It supposed run 3 times but it only runs for the first element. I have tried to run it on python console and the same approach works fine. not able to figure out the issue with code.

@api_view(['POST'])
def SaveVisitView(request):
    if request.method == 'POST':
        visits = json.loads(request.POST.get('request'))
        for i in range(len(visits['visits'])):
            serializer = VisVisitsSerializer(data=visits['visits'][i])

        if serializer.is_valid():
            serializer.save()
        else:
            return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
        return Response(serializer.data, status=status.HTTP_201_CREATED)

data

{

"visits": [ { "action": "i", "local_id": "170", "visit_id": "", "school_program_id": "1", },

{
  "action": "i",
  "local_id": "172",
  "visit_id": "",
  "school_program_id": "1",
},

{
  "action": "i",
  "local_id": "172",
  "visit_id": "",
  "school_program_id": "1",
},

] }


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Python Django Tutorial | Django Course

🔥Intellipaat Django course: https://intellipaat.com/python-django-training/ 👉This Python Django tutorial will help you learn what is django web development &...

Developing Restful APIs with Python, Django and Django Rest Framework

This article is a definitive guide for starters who want to develop projects with RESTful APIs using Python, Django and Django Rest Framework.