8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-30 08:32:26 +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 ca14749a35
commit 1a61f7a11b

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