title: django REST filter query by foreign key lookup_field
body: <p>I've got a time obj serialized to DRF.</p>
  
  <p>model:</p>
  
  <pre><code>class Time(TimeStampedModel):
      user = models.ForeignKey(
          'users.User', on_delete=models.CASCADE, related_name='time_logs')
      amount = models.DurationField()
      date_created = models.DateTimeField(auto_now_add=True)
      date_updated = models.DateTimeField(auto_now=True)
  </code></pre>
  
  <p>serializer:</p>
  
  <pre><code>class TimeSerializer(serializers.ModelSerializer):
      user = serializers.HiddenField(default=serializers.CurrentUserDefault())
  
      class Meta:
          model = Time
          fields = ('__all__')
          extra_kwargs = {'date_created': {'read_only': True}, 'date_updated': {'read_only': True}}
  </code></pre>
  
  <p>viewset:</p>
  
  <pre><code>class UserTimeViewSet(viewsets.ModelViewSet):
      serializer_class = TimeSerializer
      queryset = Time.objects.all()
  
      def get_queryset(self):
          return Time.objects.filter(user=self.request.user)
  </code></pre>
  
  <p>urls</p>
  
  <pre><code>from rest_framework.routers import DefaultRouter
  
  router = DefaultRouter()
  
  router.register(r'users/time', UserTimeViewSet)
  </code></pre>
  
  <p>this gives me an endpoint: <code>/users/time/{id}</code> where {id} is the Time obj id. when I tried to modify the endpoint to the same url route but instead pass it a user id as the arg (to get only that user's time) by overwriting <code>lookup_field</code> on the serializer and ViewSet, I'm either getting response errs or <code>{"detail":"Not found."}</code></p>
  
  <pre><code>class UserTimeViewSet(viewsets.ModelViewSet):
      serializer_class = TimeSerializer
      queryset = Time.objects.all().select_related('user')
      lookup_field = 'user'
  </code></pre>
  
  <p>also tried:</p>
  
  <pre><code>class UserTimeViewSet(generics.ListAPIView):
      serializer_class = TimeSerializer
  
      def get_queryset(self):
          user = self.kwargs['user']
          return Time.objects.filter(user=user)
  </code></pre>
  
  <p>how can I GET Time with a relationship to a user by user's id?</p>