micro_service_placeholder/microService/api/TestAPI/serializer.py

20 lines
511 B
Python
Raw Normal View History

2024-11-30 05:34:13 +00:00
from rest_framework import serializers
from api.TestAPI.model import Test
class TestSerializer(serializers.ModelSerializer):
address_title = serializers.SerializerMethodField()
class Meta:
model=Test
# fields="__all__"
fields = [
'id',
'name',
'description',
'address',
'address_title',
]
def get_address_title(self, obj):
if obj.address:
return obj.address.address
return None