strings.py 291 B

123456789101112
  1. from django.utils.encoding import smart_str
  2. def truncatechars(value: str, chars=100):
  3. """ Truncate string and append … """
  4. return (value[:chars] + "…") if len(value) > chars else value
  5. def strip(value):
  6. if not value:
  7. return ""
  8. return smart_str(value).strip()