Slice filter

1
2
3
@register.filter
def slice(s, delimiter=' '):
    return s.slice(delimiter)

More like this

  1. Word-boundary-aware string truncation template filter by josho 3 years ago
  2. Generate Javascript-Safe string in template by Spike^ekipS 5 years, 2 months ago
  3. truncatestring filter by pigletto 3 years, 2 months ago
  4. Split a string to a list and add to select options by xuqingkuang 3 years, 1 month ago
  5. JSON-compatible query filter specification by mhalle 4 years, 1 month ago

Comments

jcroft (on March 6, 2007):

The name "slice" conflicts with the built-in "slice" filter. I'd definitely recommend anyone who use this change the name, or you could be headed for troubled.

#

jacobian (on March 6, 2007):

Yeah, I'm not sure this works at all... strings don't have a "slice" method, so likely this doesn't do anything except throw an error.

#

whiskybar (on March 7, 2007):

Did you mean split?

#

sneeu (on March 14, 2007):

Ah yes, sorry - it should be called split.

#

(Forgotten your password?)