diff --git a/apps/ofm/serializers.py b/apps/ofm/serializers.py index c02cf4f1..4761e17a 100644 --- a/apps/ofm/serializers.py +++ b/apps/ofm/serializers.py @@ -96,11 +96,15 @@ class BorrowRecordSerializer(CustomModelSerializer): belong_dept_name = serializers.CharField(source='belong_dept.name', read_only=True) borrow_file = serializers.PrimaryKeyRelatedField(queryset=FileRecord.objects.all(), many=True, write_only=True, label="借阅文件") file_detail = FileRecordSerializer(source='borrow_file', many=True, read_only=True, label="借阅文件详情") + file_name = serializers.SerializerMethodField() class Meta: model = BorrowRecord fields = '__all__' read_only_fields = EXCLUDE_FIELDS + def get_file_name(self, obj): + return [file.name for file in obj.borrow_file.all()] + # class PublicitySerializer(CustomModelSerializer): # class Meta: