Skip to content

Need to set model on ModelViewSet when overriding get_queryset() #933

@awgreenblatt

Description

@awgreenblatt

In the API Guide for Viewsets, it explains how you can create a dynamic queryset by overriding the definition of get_queryset().

If you do that though, you need to set the model on the Viewset. The example in the docs does not set the model. If you don't, you'll get an error:

'name not argument not specified, and could not automatically determine the name from the viewset, as it does not have a .model or .queryset attribute.'

from get_default_base_name() in SimpleRouter.

Or, quite possibly, there's something I'm doing wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions