[PR #10970] [CLOSED] DCIM: Added sorting by Display Name to Rack Elevations (missed in #9665) #13727

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/10970
Author: @k0ste
Created: 11/18/2022
Status: Closed

Base: developHead: help


📝 Commits (1)

  • dc0a0ed DCIM: Added sorting by Display Name to Rack Elevations (missed in #9665)

📊 Changes

1 file changed (+2 additions, -0 deletions)

View changed files

📝 netbox/dcim/views.py (+2 -0)

📄 Description

#9665 introduced Rack Elevations sorting. We don't use facility_id, and sort by 'name' field works also wrong:

Look at this: 7 < 14, but not for this kind of sorting!

{
    "count": 43,
    "next": "https://netbox.example.com/api/dcim/racks/?brief=1&limit=10&offset=10&ordering=name&tag=vpc-ru-7a",
    "previous": null,
    "results": [
        {
            "id": 1729,
            "url": "https://netbox.example.com/api/dcim/racks/1729/",
            "display": "3.14.18",
            "name": "3.14.18",
            "device_count": 19
        },
        {
            "id": 1730,
            "url": "https://netbox.example.com/api/dcim/racks/1730/",
            "display": "3.14.19",
            "name": "3.14.19",
            "device_count": 16
        },
        {
            "id": 1731,
            "url": "https://netbox.example.com/api/dcim/racks/1731/",
            "display": "3.14.20",
            "name": "3.14.20",
            "device_count": 18
        },
        {
            "id": 1732,
            "url": "https://netbox.example.com/api/dcim/racks/1732/",
            "display": "3.14.21",
            "name": "3.14.21",
            "device_count": 18
        },
        {
            "id": 1733,
            "url": "https://netbox.example.com/api/dcim/racks/1733/",
            "display": "3.14.22",
            "name": "3.14.22",
            "device_count": 18
        },
        {
            "id": 1734,
            "url": "https://netbox.example.com/api/dcim/racks/1734/",
            "display": "3.14.23",
            "name": "3.14.23",
            "device_count": 17
        },
        {
            "id": 1735,
            "url": "https://netbox.example.com/api/dcim/racks/1735/",
            "display": "3.14.24",
            "name": "3.14.24",
            "device_count": 18
        },
        {
            "id": 1736,
            "url": "https://netbox.example.com/api/dcim/racks/1736/",
            "display": "3.14.25",
            "name": "3.14.25",
            "device_count": 17
        },
        {
            "id": 2723,
            "url": "https://netbox.example.com/api/dcim/racks/2723/",
            "display": "3.7.10",
            "name": "3.7.10",
            "device_count": 22
        },
        {
            "id": 2724,
            "url": "https://netbox.example.com/api/dcim/racks/2724/",
            "display": "3.7.11",
            "name": "3.7.11",
            "device_count": 23
        }
    ]
}

Then we try to sort by Display Name:

{
    "count": 43,
    "next": "https://netbox.example.com/api/dcim/racks/?brief=1&limit=10&offset=10&ordering=display&tag=vpc-ru-7a",
    "previous": null,
    "results": [
        {
            "id": 2716,
            "url": "https://netbox.example.com/api/dcim/racks/2716/",
            "display": "3.7.3",
            "name": "3.7.3",
            "device_count": 19
        },
        {
            "id": 2717,
            "url": "https://netbox.example.com/api/dcim/racks/2717/",
            "display": "3.7.4",
            "name": "3.7.4",
            "device_count": 19
        },
        {
            "id": 2718,
            "url": "https://netbox.example.com/api/dcim/racks/2718/",
            "display": "3.7.5",
            "name": "3.7.5",
            "device_count": 20
        },
        {
            "id": 2719,
            "url": "https://netbox.example.com/api/dcim/racks/2719/",
            "display": "3.7.6",
            "name": "3.7.6",
            "device_count": 21
        },
        {
            "id": 2720,
            "url": "https://netbox.example.com/api/dcim/racks/2720/",
            "display": "3.7.7",
            "name": "3.7.7",
            "device_count": 20
        },
        {
            "id": 2721,
            "url": "https://netbox.example.com/api/dcim/racks/2721/",
            "display": "3.7.8",
            "name": "3.7.8",
            "device_count": 23
        },
        {
            "id": 2722,
            "url": "https://netbox.example.com/api/dcim/racks/2722/",
            "display": "3.7.9",
            "name": "3.7.9",
            "device_count": 23
        },
        {
            "id": 2723,
            "url": "https://netbox.example.com/api/dcim/racks/2723/",
            "display": "3.7.10",
            "name": "3.7.10",
            "device_count": 22
        },
        {
            "id": 2724,
            "url": "https://netbox.example.com/api/dcim/racks/2724/",
            "display": "3.7.11",
            "name": "3.7.11",
            "device_count": 23
        },
        {
            "id": 2725,
            "url": "https://netbox.example.com/api/dcim/racks/2725/",
            "display": "3.7.12",
            "name": "3.7.12",
            "device_count": 22
        }
    ]
}

And this ordering as expected by human: all 3.7.x racks, then 3.8.x racks...


🔄 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/10970 **Author:** [@k0ste](https://github.com/k0ste) **Created:** 11/18/2022 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `help` --- ### 📝 Commits (1) - [`dc0a0ed`](https://github.com/netbox-community/netbox/commit/dc0a0ed74c1403df777de085e5da95191496a85c) DCIM: Added sorting by Display Name to Rack Elevations (missed in #9665) ### 📊 Changes **1 file changed** (+2 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/views.py` (+2 -0) </details> ### 📄 Description #9665 introduced Rack Elevations sorting. We don't use facility_id, and sort by 'name' field works also wrong: Look at this: 7 < 14, but not for this kind of sorting! ```json { "count": 43, "next": "https://netbox.example.com/api/dcim/racks/?brief=1&limit=10&offset=10&ordering=name&tag=vpc-ru-7a", "previous": null, "results": [ { "id": 1729, "url": "https://netbox.example.com/api/dcim/racks/1729/", "display": "3.14.18", "name": "3.14.18", "device_count": 19 }, { "id": 1730, "url": "https://netbox.example.com/api/dcim/racks/1730/", "display": "3.14.19", "name": "3.14.19", "device_count": 16 }, { "id": 1731, "url": "https://netbox.example.com/api/dcim/racks/1731/", "display": "3.14.20", "name": "3.14.20", "device_count": 18 }, { "id": 1732, "url": "https://netbox.example.com/api/dcim/racks/1732/", "display": "3.14.21", "name": "3.14.21", "device_count": 18 }, { "id": 1733, "url": "https://netbox.example.com/api/dcim/racks/1733/", "display": "3.14.22", "name": "3.14.22", "device_count": 18 }, { "id": 1734, "url": "https://netbox.example.com/api/dcim/racks/1734/", "display": "3.14.23", "name": "3.14.23", "device_count": 17 }, { "id": 1735, "url": "https://netbox.example.com/api/dcim/racks/1735/", "display": "3.14.24", "name": "3.14.24", "device_count": 18 }, { "id": 1736, "url": "https://netbox.example.com/api/dcim/racks/1736/", "display": "3.14.25", "name": "3.14.25", "device_count": 17 }, { "id": 2723, "url": "https://netbox.example.com/api/dcim/racks/2723/", "display": "3.7.10", "name": "3.7.10", "device_count": 22 }, { "id": 2724, "url": "https://netbox.example.com/api/dcim/racks/2724/", "display": "3.7.11", "name": "3.7.11", "device_count": 23 } ] } ``` Then we try to sort by Display Name: ``` { "count": 43, "next": "https://netbox.example.com/api/dcim/racks/?brief=1&limit=10&offset=10&ordering=display&tag=vpc-ru-7a", "previous": null, "results": [ { "id": 2716, "url": "https://netbox.example.com/api/dcim/racks/2716/", "display": "3.7.3", "name": "3.7.3", "device_count": 19 }, { "id": 2717, "url": "https://netbox.example.com/api/dcim/racks/2717/", "display": "3.7.4", "name": "3.7.4", "device_count": 19 }, { "id": 2718, "url": "https://netbox.example.com/api/dcim/racks/2718/", "display": "3.7.5", "name": "3.7.5", "device_count": 20 }, { "id": 2719, "url": "https://netbox.example.com/api/dcim/racks/2719/", "display": "3.7.6", "name": "3.7.6", "device_count": 21 }, { "id": 2720, "url": "https://netbox.example.com/api/dcim/racks/2720/", "display": "3.7.7", "name": "3.7.7", "device_count": 20 }, { "id": 2721, "url": "https://netbox.example.com/api/dcim/racks/2721/", "display": "3.7.8", "name": "3.7.8", "device_count": 23 }, { "id": 2722, "url": "https://netbox.example.com/api/dcim/racks/2722/", "display": "3.7.9", "name": "3.7.9", "device_count": 23 }, { "id": 2723, "url": "https://netbox.example.com/api/dcim/racks/2723/", "display": "3.7.10", "name": "3.7.10", "device_count": 22 }, { "id": 2724, "url": "https://netbox.example.com/api/dcim/racks/2724/", "display": "3.7.11", "name": "3.7.11", "device_count": 23 }, { "id": 2725, "url": "https://netbox.example.com/api/dcim/racks/2725/", "display": "3.7.12", "name": "3.7.12", "device_count": 22 } ] } ``` And this ordering as expected by human: all 3.7.x racks, then 3.8.x racks... --- <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 23:20:28 +01:00
adam closed this issue 2025-12-29 23:20:28 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13727