﻿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
33680	Documentation example of customising model instance loading has a bug	Ali Toosi	Ali Toosi	"The docs provide an example of how the model instance loading can be changed and how `_loaded_values` can be saved for future comparison here: https://docs.djangoproject.com/en/4.0/ref/models/instances/

In this example, it checks if there are any values not loaded from db then add them as DEFERRED values so class instantiation would work (`cls(*values)`). However, this would mean `values` list has items now that do not map to any `field_names` so when at the end of the function, we zip them together and store in `_loaded_values`, the code will fail.

The easiest fix for this is to update the `field_names` too so they would 1. work and 2. show which fields were not loaded from the db at the time.

I've opened a PR for this here: https://github.com/django/django/pull/15664"	Bug	closed	Documentation	4.0	Normal	fixed	documentation, from_db, model instance loading		Ready for checkin	1	0	0	0	1	0
