]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
views: Resolve select_related issues
authorStephen Finucane <stephen@that.guru>
Sun, 9 Oct 2016 19:07:21 +0000 (20:07 +0100)
committerStephen Finucane <stephen@that.guru>
Mon, 10 Oct 2016 21:17:02 +0000 (22:17 +0100)
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 <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
patchwork/views/rest_api.py

index d4125879deb6980d228295bbeafa4acb976c3459..9c586697660aa281eba5b214d89ea6a08e7c98d5 100644 (file)
@@ -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):