Django rest framework, should be able to override get_queryset and not define queryset attribute?
<p>I am confused. Looking through the ViewSet source code it looks like I should be able to not define a queryset in a viewset and then just override the get queryset function to get whatever queryset I want. But my code fails with this error:</p>

<pre><code>AssertionError: `base_name` argument not specified, and could not automatically determine the name from the viewset, as it does not have a `.queryset` attribute.
</code></pre>

<p>So even if I override the queryset attribute I still need to set it to some fake attribute in the beginning... this works, but it feels weird to define the queryset and then just override it a second later.</p>

<pre><code>class StudyQuestion(viewsets.ReadOnlyModelViewSet):
    queryset = Model.objects.all()
    serializer_class = ModelSerializer
    permission_classes = (permissions.IsAuthenticated, )

    def get_queryset(self):
        """"""
        return Model.objects.order_by('-word__frequency')
</code></pre>

<p>A DRF ModelViewSet uses the <code>queryset</code> to derive the URL base.  If the <code>queryset</code> property is not set, DRF asks that you use the optional <code>base_name</code> property when registering the router to declare the base.</p>

<p>Check out this page in the DRF docs:</p>

<p><a href="http://www.django-rest-framework.org/api-guide/routers/" rel="nofollow">http://www.django-rest-framework.org/api-guide/routers/</a></p>

python django django-rest-framework