31 lines
713 B
Python
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
|