13👍
Add lookup_field
to product_id
:
class ProductDetailCustom(generics.RetrieveAPIView):
lookup_field = "product_id"
queryset = Product.objects.all()
serializer_class = ProductCustomSerializer
The lookup_field
would be used by the get_object
call which would retrieve the model instance. So you can write a custom get_object
method on your view.
Ref: http://www.django-rest-framework.org/api-guide/generic-views/#genericapiview
Source:stackexchange.com