From 6b846ad0d4f7b7d0dd1feba3ec515735df2abfe1 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Mon, 19 Dec 2016 22:59:54 +0000 Subject: [PATCH] Serializer django 1.10 --- machines/serializers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/machines/serializers.py b/machines/serializers.py index 575faacd..b19294c4 100644 --- a/machines/serializers.py +++ b/machines/serializers.py @@ -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