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

Fixes #1743: Include number of instances for device types in global search

This commit is contained in:
Jeremy Stretch
2017-11-29 14:07:41 -05:00
parent 45d6955260
commit 68f76465cf

View File

@ -2,6 +2,7 @@ from __future__ import unicode_literals
from collections import OrderedDict from collections import OrderedDict
from django.db.models import Count
from django.shortcuts import render from django.shortcuts import render
from django.views.generic import View from django.views.generic import View
from rest_framework.response import Response from rest_framework.response import Response
@ -58,7 +59,7 @@ SEARCH_TYPES = OrderedDict((
'url': 'dcim:rack_list', 'url': 'dcim:rack_list',
}), }),
('devicetype', { ('devicetype', {
'queryset': DeviceType.objects.select_related('manufacturer'), 'queryset': DeviceType.objects.select_related('manufacturer').annotate(instance_count=Count('instances')),
'filter': DeviceTypeFilter, 'filter': DeviceTypeFilter,
'table': DeviceTypeTable, 'table': DeviceTypeTable,
'url': 'dcim:devicetype_list', 'url': 'dcim:devicetype_list',