mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
97c0f23c67
This might be just an oversight. Other data models do include the description in their serialisers. The API produces the description field with this change.
40 lines
826 B
Python
40 lines
826 B
Python
from rest_framework import serializers
|
|
|
|
from extras.api.serializers import CustomFieldSerializer
|
|
from tenancy.models import Tenant, TenantGroup
|
|
|
|
|
|
#
|
|
# Tenant groups
|
|
#
|
|
|
|
class TenantGroupSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
model = TenantGroup
|
|
fields = ['id', 'name', 'slug']
|
|
|
|
|
|
class TenantGroupNestedSerializer(TenantGroupSerializer):
|
|
|
|
class Meta(TenantGroupSerializer.Meta):
|
|
pass
|
|
|
|
|
|
#
|
|
# Tenants
|
|
#
|
|
|
|
class TenantSerializer(CustomFieldSerializer, serializers.ModelSerializer):
|
|
group = TenantGroupNestedSerializer()
|
|
|
|
class Meta:
|
|
model = Tenant
|
|
fields = ['id', 'name', 'slug', 'group', 'description', 'comments', 'custom_fields']
|
|
|
|
|
|
class TenantNestedSerializer(TenantSerializer):
|
|
|
|
class Meta(TenantSerializer.Meta):
|
|
fields = ['id', 'name', 'slug']
|