﻿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
37027	refresh_from_db() with from_queryset + prefetch does not persist result in instance	Hugo Maingonnat		"{{{
foo = Foo.objects.create(**data)
# The prefetch query is executed, but does not seem to be persisted into the instance
prefetch = Prefetch('bar_set', queryset=Bar.objects.all())
foo.refresh_from_db(from_queryset=Foo.objects.prefetch_related(
   prefetch
))
# This is empty
print('CACHE:', foo._prefetched_objects_cache)
# Lazy extra query is executed because prefetch was not persisted: this should not happen
list(foo.bar_set.all())
}}}

This also does not work if for example `to_attr='bar_list'` is set in the prefetch, then `foo.bar_list` is not set.

Note that using `select_related()` is working."	Bug	new	Database layer (models, ORM)	5.2	Normal		refresh_from_db, prefetch	MANAS MADESHIYA	Unreviewed	0	0	0	0	0	0
