Skip to content

Commit 9a45547

Browse files
committed
Closes #5143: Include a device's asset tag in its display value
1 parent a000ded commit 9a45547

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

docs/release-notes/version-3.1.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
### Enhancements
99

10+
* [#5143](https://github.com/netbox-community/netbox/issues/5143) - Include a device's asset tag in its display value
1011
* [#7619](https://github.com/netbox-community/netbox/issues/7619) - Permit custom validation rules to be defined as plain data or dotted path to class
1112
* [#7761](https://github.com/netbox-community/netbox/issues/7761) - Extend cable tracing across bridged interfaces
1213
* [#7769](https://github.com/netbox-community/netbox/issues/7769) - Enable assignment of IP addresses to an existing FHRP group
@@ -25,6 +26,8 @@
2526

2627
### REST API Changes
2728

29+
* dcim.Device
30+
* The `display` field now includes the device's asset tag, if set
2831
* extras.ImageAttachment
2932
* Added the `last_updated` field
3033

netbox/dcim/models/devices.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,9 @@ class Meta:
604604
)
605605

606606
def __str__(self):
607-
if self.name:
607+
if self.name and self.asset_tag:
608+
return f'{self.name} ({self.asset_tag})'
609+
elif self.name:
608610
return self.name
609611
elif self.virtual_chassis:
610612
return f'{self.virtual_chassis.name}:{self.vc_position} ({self.pk})'

0 commit comments

Comments
 (0)