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

Call Coalesce() inside get_queryset()

This commit is contained in:
Jeremy Stretch
2020-12-17 14:45:50 -05:00
parent 202e7d0ebf
commit 91083fd6c5
8 changed files with 43 additions and 49 deletions

View File

@@ -1,7 +1,6 @@
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
@@ -36,7 +35,7 @@ class SecretsRootView(APIRootView):
class SecretRoleViewSet(ModelViewSet):
queryset = SecretRole.objects.annotate(
secret_count=Coalesce(get_subquery(Secret, 'role'), 0)
secret_count=get_subquery(Secret, 'role')
)
serializer_class = serializers.SecretRoleSerializer
filterset_class = filters.SecretRoleFilterSet