Marble/server/metric/serializers.py
2024-10-09 21:15:08 +04:00

31 lines
713 B
Python

from rest_framework import serializers
from .models import Metric
class MetricSerializer(serializers.ModelSerializer):
class Meta:
model = Metric
fields = ('id',
'gender',
'weight',
'height',
'birth_date'
)
class MetricListSerializer(serializers.ModelSerializer):
email = serializers.SerializerMethodField()
class Meta:
model = Metric
fields = ('id',
'email',
'gender',
'weight',
'height',
'birth_date'
)
def get_email(self, obj):
return obj.user.email