mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 07:02:26 +00:00
Serializer django 1.10
This commit is contained in:
parent
ca14749a35
commit
1a61f7a11b
1 changed files with 5 additions and 1 deletions
|
@ -16,11 +16,15 @@ class IpListSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
class InterfaceSerializer(serializers.ModelSerializer):
|
class InterfaceSerializer(serializers.ModelSerializer):
|
||||||
ipv4 = IpListSerializer(read_only=True)
|
ipv4 = IpListSerializer(read_only=True)
|
||||||
|
mac_address = serializers.SerializerMethodField('get_macaddress')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Interface
|
model = Interface
|
||||||
fields = ('ipv4', 'mac_address', 'dns')
|
fields = ('ipv4', 'mac_address', 'dns')
|
||||||
|
|
||||||
|
def get_macaddress(self, obj):
|
||||||
|
return str(obj.mac_address)
|
||||||
|
|
||||||
class ExtensionNameField(serializers.RelatedField):
|
class ExtensionNameField(serializers.RelatedField):
|
||||||
def to_representation(self, value):
|
def to_representation(self, value):
|
||||||
return value.name
|
return value.name
|
||||||
|
|
Loading…
Reference in a new issue