I'm working on a small project using Django / Rest Framework I would like to know if there is any way to pass a list like that
mycontact = Contact.objects.get(id=[14,26,44,88])
instead of
mycontact = Contact.objects.get(id=14)
This is my full code :
@action(methods=['post'], detail=False)
def listin(self, request):
mylist = List.objects.get(id=request.data['listId'])
mycontact = Contact.objects.filter(id__in=[14,26,44,88])
mycontact.list.add(mylist)
return Response("Good")
i'm looking for a solution because I have manyTomanyField