how to make api check multiple status using drf

37

def put(self, request, *args, **kwargs):
        data = request.data
        ticket_ids = [i['ticket_id'] for i in data]
        self.validate_ids(ticket_ids)
        instances = []
        for temp_dict in data:
            ticket_id = temp_dict['ticket_id']
            name = temp_dict['name']
            description = temp_dict['description']
            obj = self.get_object(ticket_id)
            obj.name = name
            obj.description = description
            obj.save()
            instances.append(obj)
        serializer = DemoSerializer(instances, many=True)
        return Response(serializer.data)

Comments

Submit
0 Comments