Skip to content

Commit 8ea77fc

Browse files
authored
Merge pull request #2666 from pawciobiel/patch-1
Update connecting.rst - Add a note about inheritance and switch_db
2 parents 4567887 + f81e88e commit 8ea77fc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/guide/connecting.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ access to the same User document across databases::
186186
with switch_db(User, 'archive-user-db') as User:
187187
User(name='Ross').save() # Saves the 'archive-user-db'
188188

189+
.. note:: :func:`~mongoengine.context_managers.switch_db` when used on
190+
a class that allow inheritance will change the database alias
191+
for instances of a given class only - instances of subclasses will still use
192+
the default database.
189193

190194
Switch Collection
191195
-----------------

0 commit comments

Comments
 (0)