mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00: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:
@@ -23,7 +23,7 @@ from netbox.api.metadata import ContentTypeMetadata
|
||||
from netbox.api.renderers import TextRenderer
|
||||
from netbox.api.viewsets import NetBoxModelViewSet
|
||||
from utilities.exceptions import RQWorkerNotRunningException
|
||||
from utilities.utils import copy_safe_request, count_related
|
||||
from utilities.utils import copy_safe_request
|
||||
from . import serializers
|
||||
from .mixins import ConfigTemplateRenderMixin
|
||||
|
||||
@@ -147,9 +147,7 @@ class BookmarkViewSet(NetBoxModelViewSet):
|
||||
#
|
||||
|
||||
class TagViewSet(NetBoxModelViewSet):
|
||||
queryset = Tag.objects.annotate(
|
||||
tagged_items=count_related(TaggedItem, 'tag')
|
||||
)
|
||||
queryset = Tag.objects.all()
|
||||
serializer_class = serializers.TagSerializer
|
||||
filterset_class = filtersets.TagFilterSet
|
||||
|
||||
|
Reference in New Issue
Block a user