mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-26 02:18:37 -06:00
Add ordering for failing tagged-objects list API endpoint
I chose to implement this here for TaggedItemViewSet, rather than on the model, because any meaningful ordering is going to be done on the related Tag instance and I didn't want to introduce potential, not well understood side-effects by applying a model-wide ordering via a related model field.
This commit is contained in:
parent
75c726e86d
commit
6966c7ac23
@ -185,7 +185,9 @@ class TagViewSet(NetBoxModelViewSet):
|
|||||||
|
|
||||||
|
|
||||||
class TaggedItemViewSet(RetrieveModelMixin, ListModelMixin, BaseViewSet):
|
class TaggedItemViewSet(RetrieveModelMixin, ListModelMixin, BaseViewSet):
|
||||||
queryset = TaggedItem.objects.prefetch_related('content_type', 'content_object', 'tag')
|
queryset = TaggedItem.objects.prefetch_related(
|
||||||
|
'content_type', 'content_object', 'tag'
|
||||||
|
).order_by('tag__weight', 'tag__name')
|
||||||
serializer_class = serializers.TaggedItemSerializer
|
serializer_class = serializers.TaggedItemSerializer
|
||||||
filterset_class = filtersets.TaggedItemFilterSet
|
filterset_class = filtersets.TaggedItemFilterSet
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user