From 1adc56195fb57966aa119a4b411c5592743d3558 Mon Sep 17 00:00:00 2001 From: yangjian Date: Thu, 1 Jul 2021 19:26:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=90=8E=E5=8F=B0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E9=99=84=E4=BB=B6=E7=AE=A1=E7=90=86=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_api/serializers_app.py | 7 ++++++- template/app_admin/admin_attachment.html | 2 +- template/app_admin/admin_image.html | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app_api/serializers_app.py b/app_api/serializers_app.py index 88daf57..df1702e 100644 --- a/app_api/serializers_app.py +++ b/app_api/serializers_app.py @@ -64,6 +64,11 @@ class ImageGroupSerializer(ModelSerializer): # 附件序列化器 class AttachmentSerializer(ModelSerializer): + username = serializers.SerializerMethodField(label="用户名") + class Meta: model = Attachment - fields = ('__all__') \ No newline at end of file + fields = ('__all__') + + def get_username(self,obj): + return obj.user.username diff --git a/template/app_admin/admin_attachment.html b/template/app_admin/admin_attachment.html index 9082fd0..ed3be6d 100644 --- a/template/app_admin/admin_attachment.html +++ b/template/app_admin/admin_attachment.html @@ -59,7 +59,7 @@ diff --git a/template/app_admin/admin_image.html b/template/app_admin/admin_image.html index db1a131..d8ff077 100644 --- a/template/app_admin/admin_image.html +++ b/template/app_admin/admin_image.html @@ -55,7 +55,7 @@