﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34889	Broken fallback for prefetchers that only implement get_prefetch_queryset	Matt Westcott	Mariusz Felisiak	"In #33651, the `get_prefetch_queryset()` method of related managers and descriptors is deprecated in favour of `get_prefetch_querysets()`. Based on the deprecation warnings, it's clear that subclasses implementing only `get_prefetch_queryset()` are intended to continue working until this is removed outright in 6.0. However, the fallback code in `prefetch_one_level` calls it with an invalid signature:

https://github.com/django/django/blob/4e790271e3e65c9ad037b347a34fa95e11982228/django/db/models/query.py#L2535-L2562

Here the `get_prefetch_queryset` method is passed `lookup.get_current_querysets(level)` - which returns a list of querysets - as the `queryset` argument, which expects a single queryset. Changing this to `lookup.get_current_queryset(level)` fixes the problem (although it also doubles up the deprecation warnings, which may not be ideal).

Unfortunately I'm slightly stumped over how I might create a regression test for this - presumably this would involve writing a minimal related manager class that implements `get_current_queryset` but not `get_current_querysets`, but since this is an internal API it's hard to know what's considered minimal while still being a legal implementation. If it's any help, I encountered this as a regression to the `django-modelcluster` package: https://github.com/wagtail/django-modelcluster/actions/runs/6407673311/job/17394971115"	Bug	closed	Database layer (models, ORM)	5.0	Release blocker	fixed		Clément Escolano	Accepted	1	0	0	0	0	0
