Fixed internal usage of deprecated `base_objects`
Reverted the change in f898f80594 that
also replaces the internal `base_objects` with `.non_polymorphic()`.
That also changed which querysets was used. Use a clean queryset
instead that has no select-related/prefetch information, etc.. like
previous versions did.
fix_request_path_info
parent
d36f55a58f
commit
a6aa95c07e
|
|
@ -163,8 +163,11 @@ class PolymorphicModelBase(ModelBase):
|
|||
warnings.warn(
|
||||
"Using PolymorphicModel.base_objects is deprecated.\n"
|
||||
"Use {0}.objects.non_polymorphic() instead.".format(self.__class__.__name__),
|
||||
DeprecationWarning)
|
||||
DeprecationWarning, stacklevel=2)
|
||||
return self._base_objects
|
||||
|
||||
@property
|
||||
def _base_objects(self):
|
||||
# Create a manager so the API works as expected. Just don't register it
|
||||
# anymore in the Model Meta, so it doesn't substitute our polymorphic
|
||||
# manager as default manager for the third level of inheritance when
|
||||
|
|
@ -188,7 +191,7 @@ class PolymorphicModelBase(ModelBase):
|
|||
# for all supported Django versions.
|
||||
frm = inspect.stack()[1] # frm[1] is caller file name, frm[3] is caller function name
|
||||
if DUMPDATA_COMMAND in frm[1]:
|
||||
return self.base_objects
|
||||
return self._base_objects
|
||||
|
||||
manager = super(PolymorphicModelBase, self)._default_manager
|
||||
if not isinstance(manager, PolymorphicManager):
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ class PolymorphicModel(six.with_metaclass(PolymorphicModelBase, models.Model)):
|
|||
|
||||
def create_accessor_function_for_model(model, accessor_name):
|
||||
def accessor_function(self):
|
||||
attr = model.base_objects.get(pk=self.pk)
|
||||
attr = model._base_objects.get(pk=self.pk)
|
||||
return attr
|
||||
return accessor_function
|
||||
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ class PolymorphicQuerySet(QuerySet):
|
|||
# Then we copy the extra() select fields from the base objects to the real objects.
|
||||
# TODO: defer(), only(): support for these would be around here
|
||||
for real_concrete_class, idlist in idlist_per_model.items():
|
||||
real_objects = real_concrete_class.objects.non_polymorphic().using(self.db).filter(**{
|
||||
real_objects = real_concrete_class._base_objects.db_manager(self.db).filter(**{
|
||||
('%s__in' % pk_name): idlist,
|
||||
})
|
||||
real_objects.query.select_related = self.query.select_related # copy select related configuration to new qs
|
||||
|
|
|
|||
Loading…
Reference in New Issue