Template filter like truncatewords that truncates on a sentence boundary?

12 views
Skip to first unread message

Paul Souders

unread,
Dec 21, 2015, 5:59:40 PM12/21/15
to Django users

I’m looking for a template tag something like truncatewords that will truncate a string (usually: TextFields) on a sentence boundary (double newline, sentence punctuation etc.). 

I’d prefer to implement this as a template tag for maximum portability. I would use it on several projects where I can’t alter models.py.

I realize this probably involves Regular Expressions which…wow, where to start? I’m a designer & not much of a programmer. 

This seems like a really common problem and surely someone has some traction on it elsewhere.

(Cross-posted to StackOverflow if you want to answer there for extra karma)

Reply all
Reply to author
Forward
0 new messages