check before get related_objects

This commit is contained in:
a.gorbunov 2020-01-31 08:48:36 +00:00
parent c3cc87507e
commit 4ba2edecd0

View File

@ -109,8 +109,9 @@ class Collection(ProjectBaseMixin, CollectionDateMixin,
def _related_objects(self) -> list:
"""Return list of related objects."""
related_objects = []
instances = self._meta.related_objects
# get related objects
for related_object in self._meta.related_objects.with_base_related():
for related_object in instances.with_base_related() if hasattr(self, 'with_base_related') else instances:
related_objects.append(related_object)
return related_objects