英文:
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
答案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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论