-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Locations are not sorted naturally #6198
Comments
This is in a similar vein to #6179, and I support that too. Pretty much anywhere in the UI, natural sorting is what I expect. |
Easier said than done, I'm afraid. The solution I came up with in NetBox is NaturalOrderingField, which stores a "naturalized" copy of a name in the database alongside the original. The naturalized version is used for database ordering rather than the actual name. Of course, it would get rather messy trying to add this to every model with a |
Ah, that is a pain. Well, I think I can justify requesting it for least Locations, since they are a higher-touch model (at least for me). 😅 I’m surprised PG doesn’t have any better solutions for this, I would naively assume this is a common issue. |
Minor correction: currently, "Floor 1" does sort before "Floor 10". However, "Floor 10" sorts before "Floor 2" :-( |
Thanks @candlerb, I’ve corrected my report. 😆 |
Reclassifying this as a feature request simply because RackGroup (now known as Location) was not naturally ordered in previous releases. |
This might actually take a bit of effort, since Location is an MPTT-enabled model. We need to change |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide. |
Marking this as blocked by #6587 |
Not sure if it's been suggested or not, however, I find the following Python implementation adequate:
Results:
|
Unfortunately we can't rely on sorting in Python: It needs to be done at the database level. We do have some natural ordering in place for other models as mentioned above, however the use of MPTT for locations complicates things a bit. If we do end up removing MPTT under #6587 that should unblock this issue. |
Would using Collation help? From that StackOverflow post in the beginning of this thread, it looks promising. |
Relates to #11279 |
Blocked by #12552 |
Unblocking this. Let's see if we can come up with a solution that's compatible with MPTT. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide. |
This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary. |
NetBox version
2.11.0
Python version
3.7
Steps to Reproduce
Expected Behavior
In areas where Locations are displayed (e.g.
/dcim/locations
,/dcim/sites/N/
), I would expect Floor 2 to be sorted prior to Floor 10.Observed Behavior
Floor 10 is sorted prior to Floor 2.
The text was updated successfully, but these errors were encountered: