title: Retrieving a single object of interest rather than Blog.objects.all() in django rest framework
body: <p>I am comfortable using <strong>Class Based View</strong> in <strong>Django/DRF</strong> rahter than functional views. But I think my database hits is tremendously increased thus resulting my API to become slow. For eg:</p>
  <p>I have an endpoint which updates or deletes the concern object of which the id is sent in the url. My view looks like this.</p>
  <pre><code>class UpdateOrderView(UpdateAPIView,DestroyAPIView):
      permission_classes = [IsAuthenticated]    
      queryset = Order.objects.all()
      serializer_class = OrderUpdateSerializer
  
      def perform_destroy(self, instance):
          instance.delete()
  </code></pre>
  <p>As we can see above, my queryset is all the objects from Order table. If I print the queryset, it gives all the objects from the Order table which makes it slow.</p>
  <p><strong>My url is:</strong></p>
  <pre><code>path('api/updateorder/&lt;int:pk&gt;',views.UpdateOrderView.as_view(),name ='api-updateorder'),
  </code></pre>
  <p><strong>How can I get just the particular object here using id?</strong></p>
  <p>In a functional view, we can do this.</p>
  <pre><code>def Update_or_delete(request,pk)
  </code></pre>
  <p>But, pk is not recognized in the class-based view.</p>
  <p><strong>My serializer:</strong></p>
  <pre><code>class OrderUpdateSerializer(serializers.ModelSerializer):
      order_items = OrderItemUpdateSerializer(many=True)
      billing_details = BillingDetailsSerializer()
  
      class Meta:
          model = Order
          fields = ['id','ordered','order_status','order_items','total_price','billing_details']
  
  
  
      def update(self, instance, validated_data):
          # billing_details_data = validated_data.pop('billing_details', None)
          # order_items_data = validated_data.pop('order_items')
  
          #instance = super(OrderUpdateSerializer, self).update(instance,validated_data)
          #print(instance)
          instance.order_status = validated_data.get('order_status')
          instance.ordered = validated_data.get('ordered')
  
          #billing_details_logic
  
          billing_details_data = validated_data.pop('billing_details',None)
          if billing_details_data is not None:
              instance.billing_details.address = billing_details_data['address']
              instance.billing_details.save()
  
  
          #order_items_logic
  
          instance.save()
      #instance.order_items.clear()
      order_items_data = validated_data.pop('order_items')
      print(order_items_data)
  
     
      for order_item_data in order_items_data:
          oi, created = OrderItem.objects.update_or_create(
              id = order_item_data['id'],
  
              defaults={
                  'quantity' : order_item_data['quantity'],
                  'order_item_status': order_item_data['order_item_status']
              }
  
          )             
      instance.save()
      return super().update(instance,validated_data)
  </code></pre>
  <p><strong>2. My second question is this.</strong></p>
  <p>Many senior developers are a fan of using APIView in Django Rest Framework instead of using Generic Class Based Views because one can write custom code inside APIView more rather than in CBV. For eg all CRUD APIs can be integrated into a single API under APIView.</p>
  <p><strong>Is the above statement actually true?? So, should I stop using CBV and move to APIView instead? I need a clear explanation.</strong></p>