Replies: 6 comments 4 replies
-
Just a point of consideration. I often link to objects within plugins, I see that Device is already based on UUID, so I don't think I will have an issue, but just want to be consdiered. |
Beta Was this translation helpful? Give feedback.
-
Need to also think about how this impacts #1574. Are there models for whom the only natural key would be a slug? |
Beta Was this translation helpful? Give feedback.
-
We do have some models (notably CustomField, ComputedField, and Relationship -- maybe also DynamicGroup?) where a |
Beta Was this translation helpful? Give feedback.
-
I'll be clear that I certainly think we would be looking at a series of breaking changes to make this a reality.
I would argue that a slug is never a natural key because a natural key should always be a unique piece of data that exists naturally in the business use case. A slug is usually some additional data representing a denormalized copy of either a valid natural key or a composite key. Thereby, IMO, a slug is always a type of surrogate key, which exists only to serve some contrived technical need, as illustrated in my premise. |
Beta Was this translation helpful? Give feedback.
-
To further that last point, here is an example in the wild of how |
Beta Was this translation helpful? Give feedback.
-
Another case to consider: filtering and human-readable URLs.
If we're saying that we no longer care about human-readable URLs period, then so be it - just thought this was a bit distinct from the "human-readable URL for a single object" case mentioned in the OP. |
Beta Was this translation helpful? Give feedback.
-
I propose ditching the usage of slug fields altogether. I realize this might be a contentious idea, so here are my thoughts.
Slugs in their present form create bad UX when managing data
Today we have slugs all over the place as fields that users can edit. Many folks have no idea what the actual function of the slug is and why it exists. I can't count the number of times I have answered the question "what is the slug for" or "what is the purpose of this field since it duplicates the name?"
We could certainly address some of these concerns, but I truly don't see the point in favor of just ditching them.
Slugs cause surprises when permalinking
If a slug is updated for whatever reason, that record's UI link changes which is surprising to the user if they don't understand the purpose of the slug. This becomes very obvious when you have objects with simple names (e.g., one word) in which the name field and the slug contain the exact same value. The user is presented with two fields with the same value, and when their intention is to change the name, it is natural for them to also change the slug, even though it is not automatically updated for an existing record.
Also, consider automation like SSoT use cases which may change the value of the slug (either inadvertently or via a valid use case).
Slugs are great if you actually care about fancy URLs
IMO slugs in Django are great if you are running a blog where there is absolutely no reason to change the title of a post, and you want a nice-looking URL, which, more importantly, is SEO friendly. Nautobot is a data-intensive, internal IT application; our data changes, and we don't care about SEO.
Also, it's 2022, and modern browsers are removing focus from the structure and content of URLs. Safari does not even show the URL. Chrome puts focus on only the domain.
Link sharing between humans has become much more advanced. Many modern chat applications will attempt to include additional link context, like the page's title while hiding the actual text of the URL.
Our usage of slugs vs. PKs is entirely inconsistent
Sometimes we use slugs, sometimes we use the UUID PK. Our REST API uses the UUID exclusively. I know we have discussed moving towards natural keys, which alone is great, but we know in many (potentially most) cases, these will be composite keys which presents many challenges in creating workable URLs that play nice within the Django ecosystem of 3rd party apps that we rely on.
Bottom line, let's move to all UUIDs
Sure they don't look sexy, but who seriously cares enough that we are going to forgo these other points? Exposing UUIDs for record identification is a sane and standard practice that reduces overall complexity. It would allow us to be consistent across the application interfaces, and most of all, it would reduce UX toil.
I humbly submit to you nuking slugs from orbit. Please do it for the children.
Beta Was this translation helpful? Give feedback.
All reactions