[PR #1526] [MERGED] Fixes #1523 - Interface.objects.order_naturally() enhancements #12213

Closed
opened 2025-12-29 22:20:17 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/1526
Author: @tarkatronic
Created: 9/21/2017
Status: Merged
Merged: 9/22/2017
Merged by: @jeremystretch

Base: developHead: order_naturally_enhancements


📝 Commits (2)

  • 126a5e5 Fix order_naturally with unbalanced names and use RawSQL instead of extra
  • 89194c0 Another test case to ensure subinterface ordering

📊 Changes

2 files changed (+137 additions, -16 deletions)

View changed files

📝 netbox/dcim/models.py (+32 -16)
📝 netbox/dcim/tests/test_models.py (+105 -0)

📄 Description

Fixes:

  • order_naturally() will now work with unbalanced interface names, e.g., Ethernet 1/2/3, Ethernet1, Ethernet3/5/1, Ethernet2/4 will all be ordered appropriately.
  • There is now support for 3 slashes (and others are easy enough to add), to allow for Ethernet1/2/3/4.
  • .annotate() and RawSQL() is used instead of .extra() based on recommendations in the Django docs.

One other thing I have added locally, which I would like to propose, is the addition of pre_order and post_order arguments. This allows you to, for example, order all interfaces first by their device and then by the parts of the name.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/1526 **Author:** [@tarkatronic](https://github.com/tarkatronic) **Created:** 9/21/2017 **Status:** ✅ Merged **Merged:** 9/22/2017 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `order_naturally_enhancements` --- ### 📝 Commits (2) - [`126a5e5`](https://github.com/netbox-community/netbox/commit/126a5e5e4e7a74c34f63872bc5500dc5dccadbd6) Fix order_naturally with unbalanced names and use RawSQL instead of extra - [`89194c0`](https://github.com/netbox-community/netbox/commit/89194c067b89287eb5b912a01772f1aedb308ca0) Another test case to ensure subinterface ordering ### 📊 Changes **2 files changed** (+137 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/models.py` (+32 -16) 📝 `netbox/dcim/tests/test_models.py` (+105 -0) </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be opened for approval prior to filing a pull request. This helps avoid wasting time and effort on something that we might not be able to accept. Please indicate the relevant feature request or bug report below. --> ### Fixes: <!-- Please include a summary of the proposed changes below. --> * `order_naturally()` will now work with unbalanced interface names, e.g., `Ethernet 1/2/3`, `Ethernet1`, `Ethernet3/5/1`, `Ethernet2/4` will all be ordered appropriately. * There is now support for 3 slashes (and others are easy enough to add), to allow for `Ethernet1/2/3/4`. * `.annotate()` and `RawSQL()` is used instead of `.extra()` based on recommendations in the Django docs. One other thing I have added locally, which I would like to propose, is the addition of `pre_order` and `post_order` arguments. This allows you to, for example, order all interfaces first by their device and then by the parts of the name. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:20:17 +01:00
adam closed this issue 2025-12-29 22:20:17 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12213