#216 Specify `using` kwarg in get_real_instance method calls.

fix_request_path_info
Austin Matsick 2016-05-29 14:05:45 -05:00
parent 343aa41ec1
commit 2f11cb6ffd
2 changed files with 6 additions and 6 deletions

View File

@ -121,13 +121,13 @@ class PolymorphicModel(six.with_metaclass(PolymorphicModelBase, models.Model)):
return model return model
def get_real_concrete_instance_class_id(self, using=DEFAULT_DB_ALIAS): 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: if model_class is None:
return None return None
return ContentType.objects.db_manager(using).get_for_model(model_class, for_concrete_model=True).pk 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): 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: if model_class is None:
return None return None
return ContentType.objects.db_manager(using).get_for_model(model_class, for_concrete_model=True).model_class() 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 retrieve objects, then the complete object with it's real class/type
and all fields may be retrieved with this method. and all fields may be retrieved with this method.
Each method call executes one db query (if necessary).""" 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__: if real_model == self.__class__:
return self return self
return real_model.objects.db_manager(using).get(pk=self.pk) return real_model.objects.db_manager(using).get(pk=self.pk)

View File

@ -325,8 +325,8 @@ class PolymorphicQuerySet(QuerySet):
results[base_object.pk] = base_object results[base_object.pk] = base_object
else: else:
real_concrete_class = base_object.get_real_instance_class() real_concrete_class = base_object.get_real_instance_class(using=self._db)
real_concrete_class_id = base_object.get_real_concrete_instance_class_id() real_concrete_class_id = base_object.get_real_concrete_instance_class_id(using=self._db)
if real_concrete_class_id is None: if real_concrete_class_id is None:
# Dealing with a stale content type # Dealing with a stale content type
@ -372,7 +372,7 @@ class PolymorphicQuerySet(QuerySet):
for real_object in real_objects: for real_object in real_objects:
o_pk = getattr(real_object, pk_name) 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 the real class is a proxy, upcast it
if real_class != real_concrete_class: if real_class != real_concrete_class: