From 919886734656ffbc29615915b084220aa2021abc Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sun, 24 Nov 2024 23:53:44 +0800 Subject: [PATCH] Return email instead of id in document_requests list view --- docmanager_backend/document_requests/serializers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docmanager_backend/document_requests/serializers.py b/docmanager_backend/document_requests/serializers.py index 396629a..c6cd5f2 100644 --- a/docmanager_backend/document_requests/serializers.py +++ b/docmanager_backend/document_requests/serializers.py @@ -24,7 +24,8 @@ class DocumentRequestCreationSerializer(serializers.ModelSerializer): documents = DocumentRequestUnitCreationSerializer(many=True, required=True) college = serializers.CharField(max_length=64) purpose = serializers.CharField(max_length=512) - type = serializers.ChoiceField(choices=DocumentRequest.TYPE_CHOICES, required=True) + type = serializers.ChoiceField( + choices=DocumentRequest.TYPE_CHOICES, required=True) class Meta: model = DocumentRequest @@ -73,6 +74,9 @@ class DocumentRequestUnitWithFileSerializer(serializers.ModelSerializer): class DocumentRequestSerializer(serializers.ModelSerializer): documents = serializers.SerializerMethodField() + requester = serializers.SlugRelatedField( + many=False, slug_field="email", queryset=CustomUser.objects.all(), required=False + ) purpose = serializers.CharField(max_length=512) date_requested = serializers.DateTimeField( format="%m-%d-%Y %I:%M %p", read_only=True