python - Unique slugs to user -
using python library awesome-slugify creating slugs so:
unique_slug = uniqueslugify() text = 'this text' slug = unique_slug(text) # prints 'this-is-some-text'
the value of slug gets added database after it's created. if want create slug same value this-is-some-text-1
.
as application lets users create slugs, if 1 user create slug value some text
some-text
. if user create slug same value some-text-1
. if many users have same value number increase , increase.
i slugs unique user:
- user creates slug
unique_slug('hello world') # 'hello-world'
- user b creates slug
unique_slug('hello world') # 'hello-world'
- user b creates slug
unique_slug('hello world') # 'hello-world-1'
- user c creates slug
unique_slug('hello world') # 'hello-world'
as see slug unique user. doesn't matter if different users share same slug user cannot have same ones.
how go preferably using awesome-slugify or slug creation python library? thanks.
Comments
Post a Comment