From 90fe556e5fd5fbb1149fc58cca78a80022b68761 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 28 Feb 2017 16:21:31 -0500 Subject: [PATCH] Corrected region serializers --- netbox/dcim/api/serializers.py | 8 ++++---- netbox/dcim/api/views.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py index 70377b1ba68..9cae166ebdc 100644 --- a/netbox/dcim/api/serializers.py +++ b/netbox/dcim/api/serializers.py @@ -30,7 +30,7 @@ class RegionSerializer(serializers.ModelSerializer): class Meta: model = Region - fields = ['id', 'url', 'name', 'slug', 'parent'] + fields = ['id', 'name', 'slug', 'parent'] class WritableRegionSerializer(serializers.ModelSerializer): @@ -51,9 +51,9 @@ class SiteSerializer(CustomFieldModelSerializer): class Meta: model = Site fields = [ - 'id', 'name', 'slug', 'tenant', 'facility', 'asn', 'physical_address', 'shipping_address', 'contact_name', - 'contact_phone', 'contact_email', 'comments', 'custom_fields', 'count_prefixes', 'count_vlans', - 'count_racks', 'count_devices', 'count_circuits', + 'id', 'name', 'slug', 'region', 'tenant', 'facility', 'asn', 'physical_address', 'shipping_address', + 'contact_name', 'contact_phone', 'contact_email', 'comments', 'custom_fields', 'count_prefixes', + 'count_vlans', 'count_racks', 'count_devices', 'count_circuits', ] diff --git a/netbox/dcim/api/views.py b/netbox/dcim/api/views.py index 6e65ac595f7..1bf13b57bca 100644 --- a/netbox/dcim/api/views.py +++ b/netbox/dcim/api/views.py @@ -29,7 +29,7 @@ # Regions # -class RegionViewSet(WritableSerializerMixin, CustomFieldModelViewSet): +class RegionViewSet(WritableSerializerMixin, ModelViewSet): queryset = Region.objects.all() serializer_class = serializers.RegionSerializer write_serializer_class = serializers.WritableRegionSerializer @@ -40,8 +40,9 @@ class RegionViewSet(WritableSerializerMixin, CustomFieldModelViewSet): # class SiteViewSet(WritableSerializerMixin, CustomFieldModelViewSet): - queryset = Site.objects.select_related('tenant') + queryset = Site.objects.select_related('region', 'tenant') serializer_class = serializers.SiteSerializer + filter_class = filters.SiteFilter write_serializer_class = serializers.WritableSiteSerializer @detail_route()