Преглед изворни кода

Fixes #3127: Fix natural ordering of device components

Jeremy Stretch пре 6 година
родитељ
комит
5a8ba159f2
2 измењених фајлова са 12 додато и 0 уклоњено
  1. 8 0
      CHANGELOG.md
  2. 4 0
      netbox/utilities/managers.py

+ 8 - 0
CHANGELOG.md

@@ -1,3 +1,11 @@
+2.5.12 (2019-04-30)
+
+## Bug Fixes
+
+* [#3127](https://github.com/digitalocean/netbox/issues/3127) - Fix natural ordering of device components
+
+---
+
 2.5.11 (2019-04-29)
 
 ## Notes

+ 4 - 0
netbox/utilities/managers.py

@@ -37,4 +37,8 @@ class NaturalOrderingManager(Manager):
             else:
                 ordering.append(field)
 
+        # Default to using the _nat indexes if Meta.ordering is empty
+        if not ordering:
+            ordering = ('_nat1', '_nat2', '_nat3')
+
         return queryset.order_by(*ordering)