8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-26 08:53:46 +00:00

Serializer django 1.10

This commit is contained in:
Gabriel Detraz 2016-12-19 22:59:54 +00:00 committed by root
parent e6b6467ae2
commit 6b846ad0d4

View file

@ -16,11 +16,15 @@ class IpListSerializer(serializers.ModelSerializer):
class InterfaceSerializer(serializers.ModelSerializer):
ipv4 = IpListSerializer(read_only=True)
mac_address = serializers.SerializerMethodField('get_macaddress')
class Meta:
model = Interface
fields = ('ipv4', 'mac_address', 'dns')
def get_macaddress(self, obj):
return str(obj.mac_address)
class ExtensionNameField(serializers.RelatedField):
def to_representation(self, value):
return value.name