Skip to content

Commit

Permalink
Fixes #3116: Fix tagged_items count in tags API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Apr 26, 2019
1 parent 19d2850 commit d8c9b1a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* [#2621](https://github.com/digitalocean/netbox/issues/2621) - Upgrade Django requirement to 2.2 to fix object deletion issue in the changelog middleware
* [#3112](https://github.com/digitalocean/netbox/issues/3112) - Fix ordering of interface connections list by termination B name/device
* [#3116](https://github.com/digitalocean/netbox/issues/3116) - Fix `tagged_items` count in tags API endpoint

---

Expand Down
4 changes: 3 additions & 1 deletion netbox/extras/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ def render(self, request, pk):
#

class TagViewSet(ModelViewSet):
queryset = Tag.objects.annotate(tagged_items=Count('taggit_taggeditem_items'))
queryset = Tag.objects.annotate(
tagged_items=Count('taggit_taggeditem_items', distinct=True)
)
serializer_class = serializers.TagSerializer
filterset_class = filters.TagFilter

Expand Down
2 changes: 1 addition & 1 deletion netbox/extras/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class TagListView(ObjectListView):
queryset = Tag.objects.annotate(
items=Count('taggit_taggeditem_items')
items=Count('taggit_taggeditem_items', distinct=True)
).order_by(
'name'
)
Expand Down

0 comments on commit d8c9b1a

Please sign in to comment.