'"details": "not found" in django rest json response

I'm a newbie in Django Rest Framework. I am building an E-commerce API using postgresql as database for science fair project. I am getting "detail": "not found" as json response whenever I want to check the list of orders for a particular user. I have given the blocks of code below:

In views.py

class OrderListAPIView(generics.RetrieveUpdateDestroyAPIView):
    serializer_class = OrderListSerializer
    lookup_fields = ['customer']
    lookup_url_kwarg = 'customer'
    
    def get_queryset(self):
        a = Orders.objects.filter(customer=self.kwargs['customer'])
        return a

In serializers.py

class OrderListSerializer(serializers.ModelSerializer):
    product = ProductSerializer()
    class Meta:
        model = Orders
        fields = "__all__"

In urls.py

from django.urls import path

from .views import OrderListAPIView

urlpatterns = [
    path('orders/list/<customer>/', OrderListAPIView.as_view(), name='order-list')
]

Response getting from the above code

{
    "detail": "not found"
}

Expected Response

[
  {
    "ord_id": "ffa19b9b-650b-4c49-89bd-eb72f7b3c3b4",
    "product": "57cbd4a2-1c79-47a6-bf95-74ee3402e703",
    "ord_quantity": 10,
    "ord_price": 118.0,
    "ord_date": "2022-03-13T13:40:22.212586Z",
    "ord_status": "Pending",
    "customer": "08eba6ca-3f7c-4054-8184-d8ac341579e9"
  }
]

Is there anything which is wrong in these lines of code or anything which I forgot to implement or missed something?

Thanks for the help in advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source