Skip to content

Instantly share code, notes, and snippets.

@bootrino
Created August 22, 2022 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bootrino/29b0fb7c3dccdef31f6b60767b8db039 to your computer and use it in GitHub Desktop.
Save bootrino/29b0fb7c3dccdef31f6b60767b8db039 to your computer and use it in GitHub Desktop.
make_slug
def make_slug(text, randomize=False, total_length=None):
# arbitrary
text = text[:30]
# arbitrary
length = total_length or 5
if randomize:
text += '-' + shortuuid.ShortUUID('abdcefghkmnpqrstuvwxyzABDCEFGHKMNPQRSTUVWXYZ23456789').random(length=length)
if total_length:
return slugify(text)[:total_length]
return slugify(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment