1 2 3 4 5 6 7 8 9 10 11 | from django.template import Library
register = Library()
from django.template.defaultfilters import stringfilter
@register.filter
@stringfilter
def truncatestring(src, ln):
ret = src[:ln]
if len(src)>ln:
ret = ret[:ln-3]+'...'
return ret
|
More like this
- Truncate Characters Filter (simple) by leahculver 6 years, 1 month ago
- Inline truncate by character number by esanchez 4 years, 10 months ago
- truncate letters by trbs 6 years, 2 months ago
- Truncate words by characters by trodrigues 5 years ago
- truncate by alfor 6 years, 1 month ago
Comments