URL query parameters are not processed in django rest
<p>Here is my <code>views.py</code>:</p>

<pre><code>class my4appCompanyData(generics.ListAPIView):
    serializer_class = my4appSerializer

    def get_queryset(self,request):
        """Optionally restricts the returned data to ofa company,
        by filtering against a `id` query parameter in the URL. """
        queryset = companies_csrhub.objects.all()
        #url_id = self.request.query_params.get('id', None)
        url_id = request.GET.get('id', None)
        if id is not None:
            queryset = queryset.filter(id=url_id)
        elif id is ALL:
            queryset = companies_csrhub.objects.all()
        else:
            queryset = "Error data not found"
        return queryset
</code></pre>

<p>And my <code>urls.py</code>:</p>

<pre><code>router.register(r'api/my4app/company/$', views.my4appCompanyData.as_view(),base_name="company")
</code></pre>

<p>URL used for checking: <code>mywebsite/api/my4app/company/?id=100227</code></p>

<p>Planning to add multiple filters with default values but not working. Please help.</p>

<p>According the official docs (<a href="http://www.django-rest-framework.org/api-guide/filtering/#filtering-against-query-parameters" rel="nofollow">http://www.django-rest-framework.org/api-guide/filtering/#filtering-against-query-parameters</a>)</p>

<p>I think your code is not working because you are using:</p>

<pre><code>url_id = request.query_params.get('id', None)
</code></pre>

<p>Instead of:</p>

<pre><code>url_id = self.request.query_params.get('id', None)
</code></pre>

<p>In the documentation you can find that get_queryset function just receives <code>self</code> param, you must remove <code>request</code> param.</p>

python django django-views django-rest-framework