Region slug searchable #1120

Closed
opened 2025-12-29 16:29:11 +01:00 by adam · 8 comments
Owner

Originally created by @jdecorniquet on GitHub (Jul 20, 2017).

Issue type: Feature request

Hello, it would be nice to be able to search for a region slug name.

This would come very handy in case one would build a very exhaustive database of countries/provinces/cities in the following parent/child structure:

-parent name (slug)
--child name (slug)
---sub child name (slug)

Example below:

-CA (canada)
--ON (ontario)
---FAL (fort-albany)
-US (usa)
--CA (california)
---ALA (albany)
--NY (new-york)
---ALB (albany)

Having potentially thousands of city per country we could simply search for the word "albany" and see all Region elements matching or containing it. In the example above, we'd have 3 results for showing the region name, the slug and parent if any. An ouput example below as csv format:

FAL,fort-albany,ON
ALA,albany,CA
ALB,albany,NY

Thanks,

Originally created by @jdecorniquet on GitHub (Jul 20, 2017). ### Issue type: Feature request Hello, it would be nice to be able to search for a region slug name. This would come very handy in case one would build a very exhaustive database of countries/provinces/cities in the following parent/child structure: -parent name (slug) --child name (slug) ---sub child name (slug) Example below: -CA (canada) --ON (ontario) ---FAL (fort-albany) -US (usa) --CA (california) ---ALA (albany) --NY (new-york) ---ALB (albany) Having potentially thousands of city per country we could simply search for the word "albany" and see all Region elements matching or containing it. In the example above, we'd have 3 results for showing the region name, the slug and parent if any. An ouput example below as csv format: FAL,fort-albany,ON ALA,albany,CA ALB,albany,NY Thanks,
adam added the status: acceptedtype: feature labels 2025-12-29 16:29:11 +01:00
adam closed this issue 2025-12-29 16:29:12 +01:00
Author
Owner

@bellwood commented on GitHub (Jul 20, 2017):

Just as an aside to this, removing slugs from the data model was discussed earlier this year but doesn't seem to have come to a resolve:

https://groups.google.com/forum/#!searchin/netbox-discuss/slug%7Csort:relevance/netbox-discuss/SRVcWLjjoo8/_PccrV4gBwAJ

To your usage case, I agree that having a way to search within regions, especially for larger organizations, would be useful. As an Albany NY resident I approve of your example ;)

@bellwood commented on GitHub (Jul 20, 2017): Just as an aside to this, removing slugs from the data model was discussed earlier this year but doesn't seem to have come to a resolve: https://groups.google.com/forum/#!searchin/netbox-discuss/slug%7Csort:relevance/netbox-discuss/SRVcWLjjoo8/_PccrV4gBwAJ To your usage case, I agree that having a way to search within regions, especially for larger organizations, would be useful. As an Albany NY resident I approve of your example ;)
Author
Owner

@jdecorniquet commented on GitHub (Jul 20, 2017):

Thanks for the input @bellwood

Well indeed for all that is related to the Regions, I find slug extremely handy but then again that could just be replaced by a more specific field.

Eitherways, "slug" or "something more specific" does not change the original feature request of this topic. :)

@jdecorniquet commented on GitHub (Jul 20, 2017): Thanks for the input @bellwood Well indeed for all that is related to the Regions, I find slug extremely handy but then again that could just be replaced by a more specific field. Eitherways, "slug" or "something more specific" does not change the original feature request of this topic. :)
Author
Owner

@jeremystretch commented on GitHub (Jul 24, 2017):

@jdecorniquet In what context do you mean? What type of object(s) do you want to search for by region slug?

@jeremystretch commented on GitHub (Jul 24, 2017): @jdecorniquet In what context do you mean? What type of object(s) do you want to search for by region slug?
Author
Owner

@jdecorniquet commented on GitHub (Jul 24, 2017):

@jeremystretch

Well in the current version I use (v2.0.7), Region is not a searchable object yet that precisely the type I'm looking for here.

My use case has the Region's name standing for acronyms of actual cities, and there slug for the full name. Our Site naming convention includes the actual Region's acronym, so the purpose of this feature would be to ease the acronym lookup in order to create a new site.

An example would be one looking for Albany, NY's acronym by querying "albany". One would eventually find the result "ALB,albany,NY" (region name,slug,parent_region_name) and then be able to create a Site named "ALB01" for instance.

In my company's case, we dumped from NATO a complete list of North American cities (official acronym, full name, state, postal etc) and would like to import it all in our Netbox in order to have all information in one place.

I hope this helps.

@jdecorniquet commented on GitHub (Jul 24, 2017): @jeremystretch Well in the current version I use (v2.0.7), Region is not a searchable object yet that precisely the type I'm looking for here. My use case has the Region's name standing for acronyms of actual cities, and there slug for the full name. Our Site naming convention includes the actual Region's acronym, so the purpose of this feature would be to ease the acronym lookup in order to create a new site. An example would be one looking for Albany, NY's acronym by querying "albany". One would eventually find the result "ALB,albany,NY" (region name,slug,parent_region_name) and then be able to create a Site named "ALB01" for instance. In my company's case, we dumped from NATO a complete list of North American cities (official acronym, full name, state, postal etc) and would like to import it all in our Netbox in order to have all information in one place. I hope this helps.
Author
Owner

@jeremystretch commented on GitHub (Jul 27, 2017):

--CA (california)
---ALA (albany)
--NY (new-york)
---ALB (albany)

Keep in mind that slugs must be unique, so you can't have two regions with the slug "albany." Also, I would suggest swapping the fields. I would define Albany, CA as:

{
    "parent": {...},
    "name": "Albany, CA",
    "slug": "ALA"
}

This ensures that the human-friendly name is always displayed for the region. The name is also currently a unique field, although this example has me considering removing that constraint. I think it'd be reasonable to have two regions named "Albany" (but with unique slugs) since regions are arranged hierarchically (e.g. country > state > city).

@jeremystretch commented on GitHub (Jul 27, 2017): ``` --CA (california) ---ALA (albany) --NY (new-york) ---ALB (albany) ``` Keep in mind that slugs must be unique, so you can't have two regions with the slug "albany." Also, I would suggest swapping the fields. I would define Albany, CA as: ``` { "parent": {...}, "name": "Albany, CA", "slug": "ALA" } ``` This ensures that the human-friendly name is always displayed for the region. The name is also currently a unique field, although this example has me considering removing that constraint. I think it'd be reasonable to have two regions named "Albany" (but with unique slugs) since regions are arranged hierarchically (e.g. country > state > city).
Author
Owner

@jdecorniquet commented on GitHub (Jul 27, 2017):

Side question related to this topic:
Assuming one would have an exhaustive list of Regions, when creating a Site, would the drop down selection for the "Region" field be able to handle the very, very long list?
As in, is there any limitation to that currently?

I'm also considering the hassle of actually looking through that drop down selection to find the exact Region we need, even though that's a necessary evil to my case I believe.

@jdecorniquet commented on GitHub (Jul 27, 2017): Side question related to this topic: Assuming one would have an exhaustive list of Regions, when creating a Site, would the drop down selection for the "Region" field be able to handle the very, very long list? As in, is there any limitation to that currently? I'm also considering the hassle of actually looking through that drop down selection to find the exact Region we need, even though that's a necessary evil to my case I believe.
Author
Owner

@bdlamprecht commented on GitHub (Nov 20, 2017):

I'd also like to see the region be searchable as as well.
Currently, I'm testing the same basic hierarchy as @jdecorniquet is for the regions.
In my scenario, the regions (and member sites) are structured as follows:

-Geographical Region
--Country
---City
----Site 1
----Site 2

A real-world example of that would be:

-EMEA
--South Africa
---Johannesburg
----Site X
----Site Z

When fully populated against 500+ regions, the UI for that page is quite large and makes it difficult to find what you're looking for.

@bdlamprecht commented on GitHub (Nov 20, 2017): I'd also like to see the `region` be searchable as as well. Currently, I'm testing the same basic hierarchy as @jdecorniquet is for the regions. In my scenario, the `regions` (and member `sites`) are structured as follows: ``` -Geographical Region --Country ---City ----Site 1 ----Site 2 ``` A real-world example of that would be: ``` -EMEA --South Africa ---Johannesburg ----Site X ----Site Z ``` When fully populated against 500+ regions, the UI for that page is quite large and makes it difficult to find what you're looking for.
Author
Owner

@bdlamprecht commented on GitHub (Jan 30, 2018):

Really looking forward to this addition, thanks Jeremy!

@bdlamprecht commented on GitHub (Jan 30, 2018): Really looking forward to this addition, thanks Jeremy!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1120