Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expect a QuerySet for multiple defaults in MultipleObjectMixin #2191

Merged
merged 2 commits into from
Jun 28, 2024

Conversation

flaeppe
Copy link
Member

@flaeppe flaeppe commented May 28, 2024

When MultipleObjectMixin adds a more specific type than "something that can be sliced" (i.e. _SupportsPagination) for default types of queryset attributes/arguments a couple of subclass views gets a better default behaviour.

The changes here go under the same argument as in #2174 (comment)

Related issues

flaeppe added 2 commits May 28, 2024 22:31
When `MultipleObjectMixin` adds a more specific type than "something
that can be sliced" (i.e. `_SupportsPagination`) for default types of
queryset attributes/arguments a couple of subclass views gets a better
default behaviour.
@flaeppe
Copy link
Member Author

flaeppe commented Jun 28, 2024

@sobolevn and @intgr does any of you want to check this out?

@sobolevn
Copy link
Member

I think that the main reason for a protocol is that it can also paginate lists, tuples, etc:

@type_check_only
class _SupportsPagination(Protocol[_T], Sized, Iterable):
@overload
def __getitem__(self, index: int, /) -> _T: ...
@overload
def __getitem__(self, index: slice, /) -> _SupportsPagination[_T]: ...

But, anyway

@flaeppe
Copy link
Member Author

flaeppe commented Jun 28, 2024

Yes, definitely. But it conflicts with having access to builtin queryset methods e.g. .filter

@flaeppe flaeppe merged commit f3d9703 into typeddjango:master Jun 28, 2024
36 checks passed
@flaeppe flaeppe deleted the fix/list-view-get-queryset branch June 28, 2024 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

ListView.get_queryset() cannot be treated as a queryset
2 participants