]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
REST: Only call prefetch_related from a method
authorStephen Finucane <stephen@that.guru>
Tue, 7 Feb 2017 22:11:24 +0000 (22:11 +0000)
committerStephen Finucane <stephen@that.guru>
Wed, 1 Mar 2017 22:11:04 +0000 (22:11 +0000)
Calling prefetch_related on a class-level queryset variable doesn't do
anything and is a mistake. Correct this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
patchwork/api/check.py

index dcdc5c5df067cb28997fb7009aaa2097affe1931..393fcf207fc1fa53b5ab7cd5c9bab18e02834e20 100644 (file)
@@ -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."""