Skip to content

Commit a88d3d4

Browse files
committed
Fix PeerEndpoint ordering for Aurora DB
1 parent d26c876 commit a88d3d4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

nautobot_bgp_models/models.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ def local_ip(self):
487487
)
488488

489489
class Meta:
490+
ordering = ["pk"]
490491
verbose_name = "BGP Peer Endpoint"
491492

492493
def __str__(self):
@@ -553,14 +554,12 @@ class Meta:
553554
@property
554555
def endpoint_a(self):
555556
"""Get the "first" endpoint associated with this Peering."""
556-
# order_by - needed by Aurora DB, to be removed via #149
557-
return self.endpoints.order_by("pk")[0] if self.endpoints.exists() else None
557+
return self.endpoints.all()[0] if self.endpoints.exists() else None
558558

559559
@property
560560
def endpoint_z(self):
561561
"""Get the "second" endpoint associated with this Peering."""
562-
# order_by - needed by Aurora DB, to be removed via #149
563-
return self.endpoints.order_by("pk")[1] if self.endpoints.count() > 1 else None
562+
return self.endpoints.all()[1] if self.endpoints.count() > 1 else None
564563

565564
def __str__(self):
566565
"""String representation of a single Peering."""

0 commit comments

Comments
 (0)