dropbox / nsot

Network Source of Truth is an open source IPAM and network inventory database
https://nsot.readthedocs.io
Other
399 stars 66 forks source link

Add a name_slug field to Circuit, make it the natural key #259

Closed nickpegg closed 7 years ago

nickpegg commented 7 years ago

This new name_slug field is a URL-friendly version of the existing name field, which will allow us to have a friendly natural key without having to worry about conflicts with things such as slashes in the URL.

The slugification is done by our own function rather than Django's built-in slugify(). The built-in is too agressive and would cause conflicts with certain interface names. For example, since it simply drops slashes, the two following interfaces would slugify out to be the same thing, causing a uniqueness conflict:

Our slugify function simply replaces / with _, which is the bare minimum to make these names URL-friendly.

The purpose of this is the same as dropbox/nsot#258, where this fixes a bug that keeps clients from working with circuits by their name if the name contains a slash.