title: Get Object by pk in URL in Django Rest Framework
body: <p>I want to retrieve objects from the ORM by the &quot;pk&quot; in URL.
  Here's what I am trying</p>
  <p>This is my Url:</p>
  <pre><code>path('api/dispatchhistoryitem/&lt;int:pk&gt;/', views.dispatchhistoryitemsview.as_view(), 'dispatchhistoryitem'),
  </code></pre>
  <p>Views.py</p>
  <pre><code>class dispatchhistoryitemsview(ListAPIView):
      queryset = ItemBatch.objects.all()
      serializer_class = holdSerializer
  
      def get(self, request, pk, *args, **kwargs):
          items = get_object_or_404(ItemBatch, id=self.kwargs.get('pk'))
          serializer = holdSerializer(items)
          return Response(serializer.data)
  </code></pre>
  <p>Serializer.py</p>
  <pre><code>class holdSerializer(serializers.ModelSerializer):
      class Meta:
          model = ItemBatch
          fields = &quot;__all__&quot;
  </code></pre>
  <p>But when I run this it says :</p>
  <blockquote>
  <p>ValueError at /api/dispatchhistoryitem/43/</p>
  <p>dictionary update sequence element #0 has length 1; 2 is required</p>
  </blockquote>
  <p>What is that I am doing wrong here ? Please Help!</p>