diff --git a/docs/release-notes/version-3.1.md b/docs/release-notes/version-3.1.md index c4083eeec..a4deaa488 100644 --- a/docs/release-notes/version-3.1.md +++ b/docs/release-notes/version-3.1.md @@ -7,6 +7,7 @@ ### Enhancements +* [#5143](https://github.com/netbox-community/netbox/issues/5143) - Include a device's asset tag in its display value * [#7619](https://github.com/netbox-community/netbox/issues/7619) - Permit custom validation rules to be defined as plain data or dotted path to class * [#7761](https://github.com/netbox-community/netbox/issues/7761) - Extend cable tracing across bridged interfaces * [#7769](https://github.com/netbox-community/netbox/issues/7769) - Enable assignment of IP addresses to an existing FHRP group @@ -25,6 +26,8 @@ ### REST API Changes +* dcim.Device + * The `display` field now includes the device's asset tag, if set * extras.ImageAttachment * Added the `last_updated` field diff --git a/netbox/dcim/models/devices.py b/netbox/dcim/models/devices.py index 630f8606e..a2ae20319 100644 --- a/netbox/dcim/models/devices.py +++ b/netbox/dcim/models/devices.py @@ -604,7 +604,9 @@ class Device(PrimaryModel, ConfigContextModel): ) def __str__(self): - if self.name: + if self.name and self.asset_tag: + return f'{self.name} ({self.asset_tag})' + elif self.name: return self.name elif self.virtual_chassis: return f'{self.virtual_chassis.name}:{self.vc_position} ({self.pk})'