diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py
index c859508b3..21f775fd0 100644
--- a/netbox/dcim/models.py
+++ b/netbox/dcim/models.py
@@ -409,6 +409,22 @@ class DeviceType(models.Model):
def clean(self):
+ if not self.is_console_server and self.cs_port_templates.count():
+ raise ValidationError("Must delete all console server port templates associated with this device before "
+ "declassifying it as a console server.")
+
+ if not self.is_pdu and self.power_outlet_templates.count():
+ raise ValidationError("Must delete all power outlet templates associated with this device before "
+ "declassifying it as a PDU.")
+
+ if not self.is_network_device and self.interface_templates.filter(mgmt_only=False).count():
+ raise ValidationError("Must delete all non-management-only interface templates associated with this device "
+ "before declassifying it as a network device.")
+
+ if self.subdevice_role != SUBDEVICE_ROLE_PARENT and self.device_bay_templates.count():
+ raise ValidationError("Must delete all device bay templates associated with this device before "
+ "declassifying it as a parent device.")
+
if self.u_height and self.subdevice_role == SUBDEVICE_ROLE_CHILD:
raise ValidationError("Child device types must be 0U.")
diff --git a/netbox/templates/dcim/devicetype.html b/netbox/templates/dcim/devicetype.html
index 1ee2b90a8..79246046c 100644
--- a/netbox/templates/dcim/devicetype.html
+++ b/netbox/templates/dcim/devicetype.html
@@ -14,23 +14,27 @@
-{% if perms.dcim.change_devicetype %}
+
+{% if perms.dcim.change_devicetype or perms.dcim.delete_devicetype %}
{% endif %}
+
{{ devicetype }}
-
+
Chassis
@@ -76,11 +80,19 @@
{% include 'dcim/inc/devicetype_component_table.html' with table=consoleport_table title='Console Ports' add_url='dcim:devicetype_add_consoleport' delete_url='dcim:devicetype_delete_consoleport' %}
{% include 'dcim/inc/devicetype_component_table.html' with table=powerport_table title='Power Ports' add_url='dcim:devicetype_add_powerport' delete_url='dcim:devicetype_delete_powerport' %}
-
- {% include 'dcim/inc/devicetype_component_table.html' with table=devicebay_table title='Device Bays' add_url='dcim:devicetype_add_devicebay' delete_url='dcim:devicetype_delete_devicebay' %}
- {% include 'dcim/inc/devicetype_component_table.html' with table=interface_table title='Interfaces' add_url='dcim:devicetype_add_interface' delete_url='dcim:devicetype_delete_interface' %}
- {% include 'dcim/inc/devicetype_component_table.html' with table=consoleserverport_table title='Console Server Ports' add_url='dcim:devicetype_add_consoleserverport' delete_url='dcim:devicetype_delete_consoleserverport' %}
- {% include 'dcim/inc/devicetype_component_table.html' with table=poweroutlet_table title='Power Outlets' add_url='dcim:devicetype_add_poweroutlet' delete_url='dcim:devicetype_delete_poweroutlet' %}
+
+ {% if devicetype.is_network_device %}
+ {% include 'dcim/inc/devicetype_component_table.html' with table=devicebay_table title='Device Bays' add_url='dcim:devicetype_add_devicebay' delete_url='dcim:devicetype_delete_devicebay' %}
+ {% endif %}
+ {% if devicetype.is_network_device %}
+ {% include 'dcim/inc/devicetype_component_table.html' with table=interface_table title='Interfaces' add_url='dcim:devicetype_add_interface' delete_url='dcim:devicetype_delete_interface' %}
+ {% endif %}
+ {% if devicetype.is_console_server %}
+ {% include 'dcim/inc/devicetype_component_table.html' with table=consoleserverport_table title='Console Server Ports' add_url='dcim:devicetype_add_consoleserverport' delete_url='dcim:devicetype_delete_consoleserverport' %}
+ {% endif %}
+ {% if devicetype.is_pdu %}
+ {% include 'dcim/inc/devicetype_component_table.html' with table=poweroutlet_table title='Power Outlets' add_url='dcim:devicetype_add_poweroutlet' delete_url='dcim:devicetype_delete_poweroutlet' %}
+ {% endif %}
{% endblock %}