mirror of https://github.com/doccano/doccano.git
pythonannotation-tooldatasetsactive-learningtext-annotationdatasetnatural-language-processingdata-labelingmachine-learning
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
586 B
22 lines
586 B
from rest_framework import serializers
|
|
|
|
from .models import Member
|
|
|
|
|
|
class MemberSerializer(serializers.ModelSerializer):
|
|
username = serializers.SerializerMethodField()
|
|
rolename = serializers.SerializerMethodField()
|
|
|
|
@classmethod
|
|
def get_username(cls, instance):
|
|
user = instance.user
|
|
return user.username if user else None
|
|
|
|
@classmethod
|
|
def get_rolename(cls, instance):
|
|
role = instance.role
|
|
return role.name if role else None
|
|
|
|
class Meta:
|
|
model = Member
|
|
fields = ('id', 'user', 'role', 'username', 'rolename')
|