strings.py 481 B

12345678910111213141516
  1. from django.template.defaultfilters import slugify as django_slugify
  2. from django.utils import crypto
  3. try:
  4. from unidecode import unidecode
  5. use_unidecode = True
  6. except ImportError:
  7. use_unidecode = False
  8. def slugify(string):
  9. if use_unidecode:
  10. string = unidecode(string)
  11. return django_slugify(string)
  12. def random_string(length):
  13. return crypto.get_random_string(length, "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM")