Skip to content

Commit

Permalink
Corrected region serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Feb 28, 2017
1 parent c015294 commit 90fe556
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions netbox/dcim/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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',
]


Expand Down
5 changes: 3 additions & 2 deletions netbox/dcim/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 90fe556

Please sign in to comment.