From: Stephen Finucane Date: Tue, 7 Feb 2017 22:11:24 +0000 (+0000) Subject: REST: Only call prefetch_related from a method X-Git-Tag: v2.0.0-rc1~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4eb6793631d9ef59cf44991143197be9a41f5b9b;p=thirdparty%2Fpatchwork.git REST: Only call prefetch_related from a method Calling prefetch_related on a class-level queryset variable doesn't do anything and is a mistake. Correct this. Signed-off-by: Stephen Finucane Reviewed-by: Andy Doan --- diff --git a/patchwork/api/check.py b/patchwork/api/check.py index dcdc5c5d..393fcf20 100644 --- a/patchwork/api/check.py +++ b/patchwork/api/check.py @@ -88,10 +88,12 @@ class CheckSerializer(HyperlinkedModelSerializer): class CheckMixin(object): - queryset = Check.objects.prefetch_related('patch', 'user') serializer_class = CheckSerializer filter_class = CheckFilter + def get_queryset(self): + return Check.objects.prefetch_related('patch', 'user') + class CheckListCreate(CheckMixin, ListCreateAPIView): """List or create checks."""