[Answered ]-Creating object with generics CreateApiView 'request' required

1👍

You are making a super() call with the wrong parameters, it should be:

def create(self, request, *args, **kwargs):
    product_id = self.kwargs['pk']

    if Like.objects.filter(user=self.request.user, product_id=product_id).exists():
        raise ValidationError(_("This user already likes this product"))
    else:
        return super().create(request, *args, **kwargs)

0👍

The issue is how you’re calling create()

Try the below:

In the PythonKuba/api/ecommerce/views.py file

    return super().create(request=self.request, product_id=product_id, **kwargs)

At the moment you are sending in the user, not the request

Leave a comment