Ask PN:how does pythonic News generate unique slug for Url
Is it a UUID4? If it is, then does it check for uniqueness before saving into database. I was searching for a unique shortID generator using python. |
||
3 points by hackernews 2 years, 8 months ago | 3 comments | ||
2 points by sebst 2 years, 8 months ago | 2 comments | on: Ask PN:how does pythonic News generate unique slug for Url | |||||||||||||
It's using Django's UUIDField (https://docs.djangoproject.com/en/2.2/ref/models/fields/#uuidfield).
Behind the scenes, UUID4 are generated with Python's builtin uuid module. The whole point of using UUIDs is that it does not require checking for uniqueness. See for example here: https://stackoverflow.com/questions/1155008/how-unique-is-uuid
|
|||||||||||||
|