optimize collections
This commit is contained in:
parent
8a1651bf1f
commit
205e2fa996
|
|
@ -110,7 +110,7 @@ class Collection(ProjectBaseMixin, CollectionDateMixin,
|
||||||
"""Return list of related objects."""
|
"""Return list of related objects."""
|
||||||
related_objects = []
|
related_objects = []
|
||||||
# get related objects
|
# get related objects
|
||||||
for related_object in self._meta.related_objects:
|
for related_object in self._meta.related_objects.with_base_related():
|
||||||
related_objects.append(related_object)
|
related_objects.append(related_object)
|
||||||
return related_objects
|
return related_objects
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class CollectionViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
"""Overridden method 'get_queryset'."""
|
"""Overridden method 'get_queryset'."""
|
||||||
qs = models.Collection.objects.all().order_by('-created')
|
qs = models.Collection.objects.all().order_by('-created').with_base_related()
|
||||||
if self.request.country_code:
|
if self.request.country_code:
|
||||||
qs = qs.by_country_code(self.request.country_code)
|
qs = qs.by_country_code(self.request.country_code)
|
||||||
return qs
|
return qs
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user