Skip to content

get_one doesn't work well with super #309

@oburla-centumd

Description

@oburla-centumd
    def get_one(self, pk: t.Any, **kwargs: t.Any) -> t.Any:
        obj = get_object_or_exception(
            klass=self.model, error_message=None, exception=NotFound, pk=pk
        )
        return obj

so you can't provide custom queryset to klass with deep inheritance adding chains more chains because it doesn't accept it from the kwargs. Similar with the other attrs used. What if it would be like

    def get_one(self, pk: t.Any, **kwargs: t.Any) -> t.Any:
        obj = get_object_or_exception(
            klass=kwargs.get("klass") or self.model,
            error_message=kwargs.get("error_message"),
            exception=kwargs.get("exception") or NotFound,
            pk=pk
        )
        return obj

or something like that. Also it seems that klass would be better to limit to only accept QuerySet but I didn't research much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions