Skip to content

Commit 83601b9

Browse files
committed
Improved support for accessing models when using multiple databases
1 parent bd5faf0 commit 83601b9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

polymorphic/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ def __init__(self, *args, **kwargs):
200200
def create_accessor_function_for_model(model, accessor_name):
201201
def accessor_function(self):
202202
objects = getattr(model, "_base_objects", model.objects)
203-
attr = objects.get(pk=self.pk)
203+
using = kwargs.get("using", self._state.db or DEFAULT_DB_ALIAS)
204+
attr = objects.using(using).get(pk=self.pk)
204205
return attr
205206

206207
return accessor_function

0 commit comments

Comments
 (0)