django-polymorphic icon indicating copy to clipboard operation
django-polymorphic copied to clipboard

Issue with the base_objects deprecation and proxy model QuerySets

Open pfcodes opened this issue 5 years ago • 0 comments

When using a proxy model. Using ProxyModel.base_objects.all() will correctly return a QuerySet of base model instances downcasted as proxy model instances.

But using base_objects prints out this deprecation warning:

:1: DeprecationWarning: Using PolymorphicModel.base_objects is deprecated. Use PolymorphicModelBase.objects.non_polymorphic() instead.

The problem with using a PolymorphicModelBase.objects.non_polymorphic() QuerySet is that it won't downcast its instances to be proxy model instances.

I have proxy models that contain different properties and methods but refer to the same base model. Without .base_objects there is no way to get this type of QuerySet downcasted with proxy model instances.

pfcodes avatar Sep 16 '20 22:09 pfcodes