title: Django Rest Framework. How Retrieve works
body: <p>I am fairly new to Django rest framework and I had a couple questions that would really clear up a lot of stuff for me.</p>
  
  <p>I was looking at docs for simple CRUD generic views like ListAPIView, Retrieve... etc.</p>
  
  <p>For my list view I created it like this:</p>
  
  <pre><code>class CourseListApiView(ListAPIView):
      queryset = Course.objects.all()
      serializer_class = CourseListSerializer
  </code></pre>
  
  <p>Which makes sense because of the queryset returns Course.objects.all() so all the courses appear.</p>
  
  <p>What I am not clear about is how the queryset in RetrieveApi works</p>
  
  <pre><code>class CourseRetrieveAPIView(RetrieveAPIView):
      queryset = Course.objects.all()
      serializer_class = CourseRetrieveSerializer
  </code></pre>
  
  <p>This is my retrieve view, it takes pk from my link and returns a corresponding course. What is unclear to me is why the queryset is Course.objects.all(), not a filtered query that gets the kwargs from the URL and filters my Courses. I tried it my way and got the same results, my view was: </p>
  
  <pre><code>class CourseRetrieveAPIView(RetrieveAPIView):
      serializer_class = CourseRetrieveSerializer
  
      def get_queryset(self):
          queryset = Course.objects.filter(pk=self.kwargs.get('pk'))
          return queryset 
  </code></pre>
  
  <p>This makes more sense since the queryset is Course.objects.filter(pk=self.kwargs.get('pk')) instead of Course.objects.all() which to me doesn't make sense since I am filtering my courses by the pk in the URL</p>
  
  <p>Hope my question made sense. Leave a comment if you need any clarification. I know the answer will be pretty obvious but I am very new to the framework</p>