mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Standardized implementation of nested ViewSets
This commit is contained in:
@@ -2,12 +2,12 @@ from django.conf.urls import include, url
|
||||
|
||||
from rest_framework import routers
|
||||
|
||||
from views import TenantViewSet, TenantGroupViewSet
|
||||
from . import views
|
||||
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register(r'tenant-groups', TenantGroupViewSet)
|
||||
router.register(r'tenants', TenantViewSet)
|
||||
router.register(r'tenant-groups', views.TenantGroupViewSet)
|
||||
router.register(r'tenants', views.TenantViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
|
||||
|
@@ -12,9 +12,6 @@ from . import serializers
|
||||
#
|
||||
|
||||
class TenantGroupViewSet(ModelViewSet):
|
||||
"""
|
||||
List and retrieve tenant groups
|
||||
"""
|
||||
queryset = TenantGroup.objects.all()
|
||||
serializer_class = serializers.TenantGroupSerializer
|
||||
|
||||
@@ -24,9 +21,6 @@ class TenantGroupViewSet(ModelViewSet):
|
||||
#
|
||||
|
||||
class TenantViewSet(CustomFieldModelViewSet):
|
||||
"""
|
||||
List and retrieve tenants
|
||||
"""
|
||||
queryset = Tenant.objects.select_related('group')
|
||||
serializer_class = serializers.TenantSerializer
|
||||
filter_class = TenantFilter
|
||||
|
Reference in New Issue
Block a user