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:
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):
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue