24 lines
780 B
Python
24 lines
780 B
Python
# -*- coding: utf-8 -*-
|
|
from rest_framework import serializers
|
|
from apps.lyautocode.models.models_StudentManage import StudentManage
|
|
from utils.serializers import CustomModelSerializer
|
|
from utils.common import ast_convert
|
|
|
|
class StudentManageSerializer(CustomModelSerializer):
|
|
"""
|
|
学生管理 序列化器
|
|
"""
|
|
user_lyautocode_name=serializers.SerializerMethodField(read_only=True)
|
|
def get_user_lyautocode_name(self,obj):
|
|
if obj.user_id:
|
|
data = {'name': 'obj.user.name', 'mobile': 'obj.user.mobile'}
|
|
for d in data:
|
|
data[d] = eval(data[d])
|
|
return data
|
|
return ''
|
|
|
|
class Meta:
|
|
model = StudentManage
|
|
read_only_fields = ["id"]
|
|
fields = '__all__'
|