Is there a way to serialize request's payload like {'ids': [1,2,3]} as a ListField of primary keys (i.e. check by serializer whether Task objects with such ids exist)?
Or what approach should I use to write an API view for another microservice to confirm that tasks were enqueued?
serializer = ConfirmationSerializer(
data=request.data, many=True
)
queryset = Task.objects.filter(
ids_in=serializer.data.ids,
status=Task.STATUS_CREATED,
)
queryset.update(
status=Task.STATUS_SENT,
confirmed_at=dt.datetime.now()
)
return Response({'status': 'ok'})