#216 Specify `using` kwarg in get_real_instance method calls.
parent
343aa41ec1
commit
2f11cb6ffd
|
|
@ -121,13 +121,13 @@ class PolymorphicModel(six.with_metaclass(PolymorphicModelBase, models.Model)):
|
|||
return model
|
||||
|
||||
def get_real_concrete_instance_class_id(self, using=DEFAULT_DB_ALIAS):
|
||||
model_class = self.get_real_instance_class()
|
||||
model_class = self.get_real_instance_class(using=using)
|
||||
if model_class is None:
|
||||
return None
|
||||
return ContentType.objects.db_manager(using).get_for_model(model_class, for_concrete_model=True).pk
|
||||
|
||||
def get_real_concrete_instance_class(self, using=DEFAULT_DB_ALIAS):
|
||||
model_class = self.get_real_instance_class()
|
||||
model_class = self.get_real_instance_class(using=using)
|
||||
if model_class is None:
|
||||
return None
|
||||
return ContentType.objects.db_manager(using).get_for_model(model_class, for_concrete_model=True).model_class()
|
||||
|
|
@ -138,7 +138,7 @@ class PolymorphicModel(six.with_metaclass(PolymorphicModelBase, models.Model)):
|
|||
retrieve objects, then the complete object with it's real class/type
|
||||
and all fields may be retrieved with this method.
|
||||
Each method call executes one db query (if necessary)."""
|
||||
real_model = self.get_real_instance_class()
|
||||
real_model = self.get_real_instance_class(using=using)
|
||||
if real_model == self.__class__:
|
||||
return self
|
||||
return real_model.objects.db_manager(using).get(pk=self.pk)
|
||||
|
|
|
|||
|
|
@ -325,8 +325,8 @@ class PolymorphicQuerySet(QuerySet):
|
|||
results[base_object.pk] = base_object
|
||||
|
||||
else:
|
||||
real_concrete_class = base_object.get_real_instance_class()
|
||||
real_concrete_class_id = base_object.get_real_concrete_instance_class_id()
|
||||
real_concrete_class = base_object.get_real_instance_class(using=self._db)
|
||||
real_concrete_class_id = base_object.get_real_concrete_instance_class_id(using=self._db)
|
||||
|
||||
if real_concrete_class_id is None:
|
||||
# Dealing with a stale content type
|
||||
|
|
@ -372,7 +372,7 @@ class PolymorphicQuerySet(QuerySet):
|
|||
|
||||
for real_object in real_objects:
|
||||
o_pk = getattr(real_object, pk_name)
|
||||
real_class = real_object.get_real_instance_class()
|
||||
real_class = real_object.get_real_instance_class(using=self._db)
|
||||
|
||||
# If the real class is a proxy, upcast it
|
||||
if real_class != real_concrete_class:
|
||||
|
|
|
|||
Loading…
Reference in New Issue