mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-21 04:42:22 -06:00
* Introduce RelatedObjectCountField * Introduce get_annotations_for_serializer() and enable dynamic annotations * Add RelatedObjectCountFields to serializers; remove static annotations from querysets * Remove annotations cleanup logic from BriefModeMixin * Annotate type for RelatedObjectCountField * Remove redundant field on TagSerializer * Add missing reverse relationship for power feeds to rack * Refactor RelatedObjectCountField to take a single relationship name
This commit is contained in:
@@ -4,7 +4,6 @@ from circuits import filtersets
|
||||
from circuits.models import *
|
||||
from dcim.api.views import PassThroughPortMixin
|
||||
from netbox.api.viewsets import NetBoxModelViewSet
|
||||
from utilities.utils import count_related
|
||||
from . import serializers
|
||||
|
||||
|
||||
@@ -21,9 +20,7 @@ class CircuitsRootView(APIRootView):
|
||||
#
|
||||
|
||||
class ProviderViewSet(NetBoxModelViewSet):
|
||||
queryset = Provider.objects.annotate(
|
||||
circuit_count=count_related(Circuit, 'provider')
|
||||
)
|
||||
queryset = Provider.objects.all()
|
||||
serializer_class = serializers.ProviderSerializer
|
||||
filterset_class = filtersets.ProviderFilterSet
|
||||
|
||||
@@ -33,9 +30,7 @@ class ProviderViewSet(NetBoxModelViewSet):
|
||||
#
|
||||
|
||||
class CircuitTypeViewSet(NetBoxModelViewSet):
|
||||
queryset = CircuitType.objects.annotate(
|
||||
circuit_count=count_related(Circuit, 'type')
|
||||
)
|
||||
queryset = CircuitType.objects.all()
|
||||
serializer_class = serializers.CircuitTypeSerializer
|
||||
filterset_class = filtersets.CircuitTypeFilterSet
|
||||
|
||||
|
||||
Reference in New Issue
Block a user