Merge branch 'bug/fix-related-objects-for-collections' into 'develop'

check before get related_objects

See merge request gm/gm-backend!252
This commit is contained in:
Anton Gorbunov 2020-01-31 08:49:15 +00:00
commit ac53543dc7

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