Message ID | 20170207221124.18103-1-stephen@that.guru |
---|---|
State | Accepted |
Headers | show |
On 02/07/2017 04:11 PM, Stephen Finucane wrote: > 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> > Cc: Andy Doan <andy.doan@linaro.org> Reviewed-by: Andy Doan <andy.doan@linaro.org>
diff --git a/patchwork/api/check.py b/patchwork/api/check.py index dcdc5c5..393fcf2 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."""
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> Cc: Andy Doan <andy.doan@linaro.org> --- patchwork/api/check.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)