title: Django Rest Framework - Query for exact match on two fields in a mapping table
body: <p>I'm using DRF and trying to search a mapping table for exact matches so I can update that record.</p>
  
  <p>I have the following tables:</p>
  
  <pre><code>site
  - id
  - location
  - address
  
  circuit
  - id
  - name
  - ref
  
  sitecircuits
  - site_id
  - circuit_id
  - active_link
  </code></pre>
  
  <p>my current DRF config as below:</p>
  
  <p>view</p>
  
  <pre><code>class MonitoringConnectivitySet(viewsets.ModelViewSet):
      queryset = SiteCircuits.objects.all()
      serializer_class = MonitoringSerializerConnectivity
      permission_classes = (IsAdminUser,)   
      filter_class = SiteCircuits
      filter_backends = (filters.SearchFilter,)
      search_fields = ('site__id','circuit__id') 
  </code></pre>
  
  <p>serialiser</p>
  
  <pre><code>class MonitoringSerializerConnectivity(serializers.ModelSerializer):
  
      class Meta:
          model = SiteCircuits
          fields = ('site_id','circuit_id','active_link',) 
  </code></pre>
  
  <p>url</p>
  
  <pre><code>router.register(r'conn_set', views.MonitoringConnectivitySet)
  </code></pre>
  
  <p>this url <a href="http://localhost:8100/api/conn_set/?site__id=8&amp;circuit__id=7" rel="nofollow noreferrer">http://localhost:8100/api/conn_set/?site__id=8&amp;circuit__id=7</a>
  returns all the results (as I doesn't search at all)</p>
  
  <p>ive also tried using the below</p>
  
  <p>url: </p>
  
  <pre><code>path('conn_set/&lt;int:site_id&gt;/&lt;int:circuit_id&gt;/', views.MonitoringConnectivitySet)
  </code></pre>
  
  <p>serialiser:</p>
  
  <pre><code>class MonitoringSerializerConnectivity(serializers.ModelSerializer):
  
      class Meta:
          model = SiteCircuits
          fields = ('site_id','circuit_id','active_link',) 
  
      def get_queryset(self):
              site_id = self.kwargs['site_id']
              circuit_id = self.kwargs['circuit_id']
              return SiteCircuits.objects.filter(site_id=site_id,circuit_id=circuit_id)        
  </code></pre>
  
  <p>view:</p>
  
  <pre><code>class MonitoringConnectivitySet(viewsets.ModelViewSet):
      queryset = SiteCircuits.objects.all()
      serializer_class = MonitoringSerializerConnectivity
      permission_classes = (IsAdminUser,)   
  </code></pre>
  
  <p>which also fails when using the url (indicating it only takes one value not two
  <a href="http://localhost:8100/api/conn_set/8/7" rel="nofollow noreferrer">http://localhost:8100/api/conn_set/8/7</a></p>
  
  <p>does anyone know the right combination here? is there any special needed to be done to filter and update the mapping table?</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>when overriding the QuerySet I now get the following error:</p>
  
  <pre><code>Traceback:
  
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
    34.             response = get_response(request)
  
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
    115.                 response = self.process_exception_by_middleware(e, request)
  
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
    113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)
  
  File "/usr/local/lib/python3.6/site-packages/django/views/decorators/csrf.py" in wrapped_view
    54.         return view_func(*args, **kwargs)
  
  File "/usr/local/lib/python3.6/site-packages/rest_framework/viewsets.py" in view
    116.             return self.dispatch(request, *args, **kwargs)
  
  File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
    495.             response = self.handle_exception(exc)
  
  File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py" in handle_exception
    455.             self.raise_uncaught_exception(exc)
  
  File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py" in raise_uncaught_exception
    466.         raise exc
  
  File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
    492.             response = handler(request, *args, **kwargs)
  
  File "/usr/local/lib/python3.6/site-packages/rest_framework/mixins.py" in list
    40.         queryset = self.filter_queryset(self.get_queryset())
  
  File "/usr/local/lib/python3.6/site-packages/rest_framework/generics.py" in filter_queryset
    152.             queryset = backend().filter_queryset(self.request, queryset, self)
  
  File "/usr/local/lib/python3.6/site-packages/django_filters/rest_framework/backends.py" in filter_queryset
    90.         filterset = self.get_filterset(request, queryset, view)
  
  File "/usr/local/lib/python3.6/site-packages/django_filters/rest_framework/backends.py" in get_filterset
    36.         return filterset_class(**kwargs)
  
  File "/usr/local/lib/python3.6/site-packages/django/db/models/base.py" in __init__
    501.                 raise TypeError("%s() got an unexpected keyword argument '%s'" % (cls.__name__, kwarg))
  
  Exception Type: TypeError at /api/conn_set/
  Exception Value: SiteCircuits() got an unexpected keyword argument 'data'
  </code></pre>