将URL参数进行哈希处理并映射到数据库时,这被称为什么?

huangapple go评论59阅读模式
英文:

What is it called when you hash a URL params and map it to the database?

问题

嗨,我正在使用Django作为后端,我一直在尝试搜索这个术语,但似乎找不到。

例如,Spotify有一个歌曲的URL:https://open.spotify.com/track/0feI2qZLlaapheeJeznYwZ

我猜想这个哈希ID映射到其中一个自动生成的ID。

我应该搜索什么来在我的应用中实现这个?

非常感谢提前帮助!

英文:

Hi I'm working with Django as my backend and I've been trying to search up this term but I can't seem to find it.

For example Spotify has a URL for a song https://open.spotify.com/track/0feI2qZLlaapheeJeznYwZ

I'm guessing the hashed ID maps to one of the autogenerated ID's.

What would I search up to implement this in my app ?

Any references will be greatly appreciated.

Thanks in advance 将URL参数进行哈希处理并映射到数据库时,这被称为什么?

答案1

得分: 1

非常常见的是使用UUID:
https://example.com/users/ab45765d-9092-4cbd-8402-a9b788c08d6a/

有Django.models.UUIDField:https://docs.djangoproject.com/en/4.2/ref/models/fields/#uuidfield

将其用于您的id/pk模型字段,您的detail链接将使用此UUID字段而不是整数slug

英文:

Very often UUID is used:
https://example.com/users/ab45765d-9092-4cbd-8402-a9b788c08d6a/

there is Django.models.UUIDField: https://docs.djangoproject.com/en/4.2/ref/models/fields/#uuidfield

Use it for your id/pk model field and your detail links will be with this uuid field instead of integers or slug.

huangapple
  • 本文由 发表于 2023年5月22日 12:05:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76302978.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定