[Answered ]-Can't pass parameters in Django, giving MultiValueDictKeyError

1👍

class TrainModel(APIView):
    permission_classes = (IsAuthenticated,)

    def post(self, request):
        data = request.data # I would suggest using a serializer and it automatically validates your data 

        fit_model(data, "")
        model_name = "{}-{}-{}-{}".format(
            data.get("match_slug"), data.get("match_id"), data.get("model_type"), data.get("version"))

        response = {
            "success": True,
            "message": "Model is being trained please wait",
            "data": {"model_name": model_name}
        }

        return Response(response, status=status.HTTP_200_OK)

Leave a comment