[Django]-Django rest framework, should be able to override get_queryset and not define queryset attribute?

3👍

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

Check out this page in the DRF docs:

http://www.django-rest-framework.org/api-guide/routers/

2👍

DRF Router is complaining, because it can’t automatically generate a basename for the viewset:

base_name – The base to use for the URL names that are created. If unset the basename will be automatically generated based on the queryset attribute of the viewset, if it has one. Note that if the viewset does not include a queryset attribute then you must set base_name when registering the viewset.

👤C14L

Leave a comment