Closes #5143: Include a device's asset tag in its display value

This commit is contained in:
jeremystretch 2021-11-17 13:06:57 -05:00
parent a000ded350
commit 9a45547cda
2 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -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})'