1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes: #5450 - Added Coalesce to viewsets for the _count functions

This commit is contained in:
Daniel Sheppard
2020-12-15 12:50:28 -06:00
committed by GitHub
parent 67f9e16905
commit 3c2b2f26b9
8 changed files with 49 additions and 41 deletions

View File

@ -1,6 +1,7 @@
import base64
from Crypto.PublicKey import RSA
from django.db.models.functions import Coalesce
from django.http import HttpResponseBadRequest
from rest_framework.exceptions import ValidationError
from rest_framework.permissions import IsAuthenticated
@ -35,7 +36,7 @@ class SecretsRootView(APIRootView):
class SecretRoleViewSet(ModelViewSet):
queryset = SecretRole.objects.annotate(
secret_count=get_subquery(Secret, 'role')
secret_count=Coalesce(get_subquery(Secret, 'role'), 0)
)
serializer_class = serializers.SecretRoleSerializer
filterset_class = filters.SecretRoleFilterSet