Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
speed up outbound table
Browse files Browse the repository at this point in the history
  • Loading branch information
monty5811 committed Dec 4, 2015
1 parent 8d195b7 commit 30dec56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
model_class=SmsOutbound,
serializer_class=SmsOutboundSerializer,
permission_classes=(IsAuthenticated, CanSeeOutgoing),
related_field='recipient',
),
name='out_log'),
url(r'^v1/sms/live_wall/in/$',
Expand Down
7 changes: 6 additions & 1 deletion api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ class ApiCollection(APIView):
permission_classes = (IsAuthenticated,)
model_class = None
serializer_class = None
related_field = None
filter_list = False
filters = {}

def get(self, request, format=None):
objs = self.model_class.objects.all()
if self.related_field is None:
objs = self.model_class.objects.all()
else:
objs = self.model_class.objects.all(
).select_related(self.related_field)
if self.filter_list:
objs = objs.filter(**self.filters)
serializer = self.serializer_class(objs, many=True)
Expand Down

0 comments on commit 30dec56

Please sign in to comment.