What's the use for slugs in NetBox 2.11+? #6194
-
I'm successfully working with a NetBox-based automation project (2+ years now) where we have created the slugs as random strings. That's because in that system the site names can change any time, so we have wanted to keep the slugs meaningless to discourage changing them in GUI while changing the site name, as the slugs have been used in the URLs. Now that the URLs no longer carry the slugs in NetBox 2.11+, the situation is different: it doesn't harm us if the slugs change. So, what's the use for slugs ("URL-friendly unique shorthand" as help texts in GUI say) at the moment? Actually, I see that if I want to filter objects by tags in the API, I have to use the tag slugs, I cannot use tag ID or a dict describing the tag (unless I did something wrong!). Is that the only use case for slugs, or are there others? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Personally, I'd like to see slugs phased out completely (hence the change in #5873 to all ID-based URLs). We didn't want to just drop slugs completely, though, because some users rely on them to store necessary information (e.g. site codes). |
Beta Was this translation helpful? Give feedback.
-
In the long run, I'd like to see slugs become GUIDs that you could use to reference any object instead of its numeric ID. This would allow you to export/import/sync objects between different environments, where the database-allocated sequential ID may be different. A CSV column with GUID would allow you both to import objects (if the GUID doesn't exist) and update objects (if the GUID matches an existing object). Aside: at the moment, many objects now have id and slug and name and display (at least in the API), which seems redundant. In the case of
Given that there's an ID and/or slug for API use, I don't see why both "name" and "display" are needed - who is ever going to see "name"? Although I can see why you might want "display:en", "display:es", "display:fr" etc. |
Beta Was this translation helpful? Give feedback.
Personally, I'd like to see slugs phased out completely (hence the change in #5873 to all ID-based URLs). We didn't want to just drop slugs completely, though, because some users rely on them to store necessary information (e.g. site codes).