Issue #373 : Fix bug with get_real_instances on empty base_result_objects

This commit is contained in:
gtors
2019-01-30 14:36:21 +03:00
committed by Diederik van der Boor
parent 26fac56e31
commit f06a02a3d0
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -474,7 +474,7 @@ class PolymorphicQuerySet(QuerySet):
:rtype: PolymorphicQuerySet
"""
"same as _get_real_instances, but make sure that __repr__ for ShowField... creates correct output"
if not base_result_objects:
if base_result_objects is None:
base_result_objects = self
olist = self._get_real_instances(base_result_objects)
if not self.model.polymorphic_query_multiline_output:
+8
View File
@@ -332,6 +332,14 @@ class PolymorphicTests(TransactionTestCase):
transform=lambda o: o.__class__,
)
# from empty list
objects = Model2A.objects.get_real_instances([])
self.assertQuerysetEqual(
objects,
[],
transform=lambda o: o.__class__,
)
def test_translate_polymorphic_q_object(self):
self.create_model2abcd()