From: Stephen Finucane Date: Sun, 9 Oct 2016 19:07:21 +0000 (+0100) Subject: views: Resolve select_related issues X-Git-Tag: v2.0.0-rc1~198 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c2dbf6c4537e5f90e88c8308fcb5d839330b458;p=thirdparty%2Fpatchwork.git views: Resolve select_related issues Django 1.10 prohibits non-relational fields for nested relations [1]. Replace said call with a functional alternative. [1] https://docs.djangoproject.com/en/dev/releases/1.10/#select-related-prohibits-non-relational-fields-for-nested-relations Signed-off-by: Stephen Finucane Reviewed-by: Daniel Axtens --- diff --git a/patchwork/views/rest_api.py b/patchwork/views/rest_api.py index d4125879..9c586697 100644 --- a/patchwork/views/rest_api.py +++ b/patchwork/views/rest_api.py @@ -94,7 +94,7 @@ class PeopleViewSet(PatchworkViewSet): def get_queryset(self): qs = super(PeopleViewSet, self).get_queryset() - return qs.select_related('user__username') + return qs.prefetch_related('user') class ProjectViewSet(PatchworkViewSet):