Skip to content

Commit edd8997

Browse files
Fixed #29762 -- Doc'd how database routers fetch related objects.
Thanks James Bligh for the review. Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
1 parent 4fd9e85 commit edd8997

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

docs/topics/db/multi-db.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ cases, no instance hint will be provided at all. The router checks for
232232
the existence of an instance hint, and determine if that hint should be
233233
used to alter routing behavior.
234234

235+
If an ``instance`` hint is present, the database from which it was fetched
236+
is recorded on its :attr:`instance._state.db <django.db.models.Model._state>`.
237+
Routers will need to first consult that attribute before falling back to any
238+
fixed alias to match Django's default behavior of fetching related instances
239+
from the same database.
240+
235241
Using routers
236242
-------------
237243

0 commit comments

Comments
 (0)