1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #6179: Enable natural ordering for virtual machines

This commit is contained in:
jeremystretch
2021-04-20 09:17:14 -04:00
parent 497e50c559
commit 9ed76400de
3 changed files with 39 additions and 1 deletions

View File

@@ -226,6 +226,11 @@ class VirtualMachine(PrimaryModel, ConfigContextModel):
name = models.CharField(
max_length=64
)
_name = NaturalOrderingField(
target_field='name',
max_length=100,
blank=True
)
status = models.CharField(
max_length=50,
choices=VirtualMachineStatusChoices,
@@ -296,7 +301,7 @@ class VirtualMachine(PrimaryModel, ConfigContextModel):
]
class Meta:
ordering = ('name', 'pk') # Name may be non-unique
ordering = ('_name', 'pk') # Name may be non-unique
unique_together = [
['cluster', 'tenant', 'name']
]