diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py
index cee516f5c..87c4828d5 100644
--- a/netbox/dcim/views.py
+++ b/netbox/dcim/views.py
@@ -328,6 +328,11 @@ class SiteView(generic.ObjectView):
'device_count',
cumulative=True
).restrict(request.user, 'view').filter(site=instance)
+ nonracked_devices = Device.objects.filter(
+ site=instance,
+ position__isnull=True,
+ parent_bay__isnull=True
+ ).prefetch_related('device_type__manufacturer')
asns = ASN.objects.restrict(request.user, 'view').filter(sites=instance)
asn_count = asns.count()
@@ -338,6 +343,7 @@ class SiteView(generic.ObjectView):
'stats': stats,
'locations': locations,
'asns': asns,
+ 'nonracked_devices': nonracked_devices,
}
@@ -415,11 +421,17 @@ class LocationView(generic.ObjectView):
).filter(pk__in=location_ids).exclude(pk=instance.pk)
child_locations_table = tables.LocationTable(child_locations)
paginate_table(child_locations_table, request)
+ nonracked_devices = Device.objects.filter(
+ location=instance,
+ position__isnull=True,
+ parent_bay__isnull=True
+ ).prefetch_related('device_type__manufacturer')
return {
'rack_count': rack_count,
'device_count': device_count,
'child_locations_table': child_locations_table,
+ 'nonracked_devices': nonracked_devices,
}
diff --git a/netbox/templates/dcim/inc/nonracked_devices.html b/netbox/templates/dcim/inc/nonracked_devices.html
new file mode 100644
index 000000000..f1b669eb9
--- /dev/null
+++ b/netbox/templates/dcim/inc/nonracked_devices.html
@@ -0,0 +1,62 @@
+{% load helpers %}
+
+
+
+
+{% if nonracked_devices %}
+
+
+ Name |
+ Role |
+ Type |
+ Parent Device |
+
+ {% for device in nonracked_devices %}
+
+
+ {{ device }}
+ |
+ {{ device.device_role }} |
+ {{ device.device_type }} |
+ {% if device.parent_bay %}
+ {{ device.parent_bay.device }} |
+ {{ device.parent_bay }} |
+ {% else %}
+ — |
+ {% endif %}
+
+ {% endfor %}
+
+ {% else %}
+
+ None
+
+ {% endif %}
+
+ {% if perms.dcim.add_device %}
+ {% if object|meta:'verbose_name' == 'rack' %}
+
+ {% elif object|meta:'verbose_name' == 'site' %}
+
+ {% elif object|meta:'verbose_name' == 'location' %}
+
+ {% endif %}
+ {% endif %}
+
\ No newline at end of file
diff --git a/netbox/templates/dcim/location.html b/netbox/templates/dcim/location.html
index b684385a7..43bbfd114 100644
--- a/netbox/templates/dcim/location.html
+++ b/netbox/templates/dcim/location.html
@@ -90,6 +90,7 @@
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/contacts.html' %}
+ {% include 'dcim/inc/nonracked_devices.html' %}
{% include 'inc/panels/image_attachments.html' %}
{% plugin_right_page object %}
diff --git a/netbox/templates/dcim/rack.html b/netbox/templates/dcim/rack.html
index 93bd21fd9..4eb94a0ce 100644
--- a/netbox/templates/dcim/rack.html
+++ b/netbox/templates/dcim/rack.html
@@ -288,50 +288,7 @@
-
-
-
- {% if nonracked_devices %}
-
-
- Name |
- Role |
- Type |
- Parent Device |
-
- {% for device in nonracked_devices %}
-
-
- {{ device }}
- |
- {{ device.device_role }} |
- {{ device.device_type }} |
- {% if device.parent_bay %}
- {{ device.parent_bay.device }} |
- {{ device.parent_bay }} |
- {% else %}
- — |
- {% endif %}
-
- {% endfor %}
-
- {% else %}
-
- None
-
- {% endif %}
-
- {% if perms.dcim.add_device %}
-
- {% endif %}
-
+ {% include 'dcim/inc/nonracked_devices.html' %}
{% include 'inc/panels/contacts.html' %}
{% plugin_right_page object %}
diff --git a/netbox/templates/dcim/site.html b/netbox/templates/dcim/site.html
index f71105d1b..aa17fd57f 100644
--- a/netbox/templates/dcim/site.html
+++ b/netbox/templates/dcim/site.html
@@ -277,6 +277,7 @@
+ {% include 'dcim/inc/nonracked_devices.html' %}
{% include 'inc/panels/contacts.html' %}