feat: ofm-serializer fix
This commit is contained in:
parent
6b08200016
commit
e7ea16ece6
|
@ -96,11 +96,15 @@ class BorrowRecordSerializer(CustomModelSerializer):
|
||||||
belong_dept_name = serializers.CharField(source='belong_dept.name', read_only=True)
|
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="借阅文件")
|
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_detail = FileRecordSerializer(source='borrow_file', many=True, read_only=True, label="借阅文件详情")
|
||||||
|
file_name = serializers.SerializerMethodField()
|
||||||
class Meta:
|
class Meta:
|
||||||
model = BorrowRecord
|
model = BorrowRecord
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
read_only_fields = EXCLUDE_FIELDS
|
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 PublicitySerializer(CustomModelSerializer):
|
||||||
# class Meta:
|
# class Meta:
|
||||||
|
|
Loading…
Reference in New Issue