From 8556190117c357cda12c052b4287f4be6919c50b Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Mon, 23 Jan 2023 15:16:29 -0500 Subject: [PATCH] Minor fixes/optimizations for API endpoints --- membershipworks/api.py | 4 ++-- paperwork/api.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/membershipworks/api.py b/membershipworks/api.py index c34214d..b47defa 100644 --- a/membershipworks/api.py +++ b/membershipworks/api.py @@ -1,6 +1,6 @@ from rest_framework import routers, serializers, viewsets -from .models import Member, MemberFlag, Flag +from .models import Member, Flag class MemberSerializer(serializers.HyperlinkedModelSerializer): @@ -10,7 +10,7 @@ class MemberSerializer(serializers.HyperlinkedModelSerializer): class MemberViewSet(viewsets.ModelViewSet): - queryset = Member.objects.all() + queryset = Member.objects.prefetch_related("flags") serializer_class = MemberSerializer diff --git a/paperwork/api.py b/paperwork/api.py index 8b5a991..ba6812c 100644 --- a/paperwork/api.py +++ b/paperwork/api.py @@ -103,7 +103,7 @@ class DepartmentViewSet(viewsets.ModelViewSet): class CertificationDefinitionSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = CertificationDefinition - fields = ["certification_name", "department", "mailing_list"] + fields = ["certification_name", "department"] class CertificationDefinitionViewSet(viewsets.ModelViewSet):