add city & province name to user serializer
This commit is contained in:
@@ -94,6 +94,11 @@ class UserSerializer(serializers.ModelSerializer):
|
||||
'otp_status',
|
||||
'is_herd_owner',
|
||||
]
|
||||
extra_kwargs = {
|
||||
'password': {
|
||||
'required': False
|
||||
}
|
||||
}
|
||||
|
||||
def to_representation(self, instance):
|
||||
""" Custom output """
|
||||
@@ -105,10 +110,8 @@ class UserSerializer(serializers.ModelSerializer):
|
||||
).data
|
||||
|
||||
if instance.city:
|
||||
representation['city_id'] = instance.city.id
|
||||
representation['city_name'] = instance.city.name
|
||||
if instance.province:
|
||||
representation['province_id'] = instance.province.id
|
||||
representation['province_name'] = instance.province.name
|
||||
|
||||
return representation
|
||||
|
||||
Reference in New Issue
Block a user