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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -