[Django] #37259: Model.from_db() overrides without fetch_mode argument crash with TypeError on any query

2 views
Skip to first unread message

Django

unread,
Aug 8, 2026, 5:44:59 PM (2 days ago) Aug 8
to django-...@googlegroups.com
#37259: Model.from_db() overrides without fetch_mode argument crash with TypeError
on any query
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: Adam Johnson
Johnson |
Type: Bug | Status: assigned
Component: Database | Version: 6.1
layer (models, ORM) |
Severity: Release | Keywords:
blocker |
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
The fetch modes feature added in Django 6.1 (#28586) made every query
iteration path pass a new `fetch_mode` keyword argument to
`Model.from_db()`. Any model that overrides `from_db()` with the
signature documented in the model instance reference —
`from_db(cls, db, field_names, values)`, including the documented
`_loaded_values` example — now crashes on **any** database fetch:

{{{
TypeError: MyModel.from_db() got an unexpected keyword argument
'fetch_mode'
}}}

This worked on Django 6.0 and all earlier versions.

The proposed fix is to deprecate `from_db()` overrides that do not accept
the new `fetch_mode` keyword argument, using `django.utils.inspect` to
detect the override signature and conditionally pass `fetch_mode` or not,
emitting a `RemovedInDjango70Warning` for old-signature overrides.
--
Ticket URL: <https://code.djangoproject.com/ticket/37259>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 8, 2026, 5:53:16 PM (2 days ago) Aug 8
to django-...@googlegroups.com
#37259: Model.from_db() overrides without fetch_mode argument crash with TypeError
on any query
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: assigned
Component: Database layer | Version: 6.1
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam Johnson):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/37259#comment:1>
Reply all
Reply to author
Forward
0 new messages