django template filter ,use 2 or more filter like pipe
django, django-template-filters
Solution
First, the answer for your question "Does django only support one filter?" is that Django does support almost unlimited number of chained filters (depends on your platform and ability to write that number of chained filters of course =) . Take some code for example (not proof but it makes sense), it is actually a template `'{{ x|add:1|add:1|...10000 in all...|add:1 }}'`
>>> from django.template import *
>>> t = Template('{{ x|'+'|'.join(['add:1']*10000)+' }}')
>>> t.render(Context({'x':0}))
u'10000'
Second, please check the template to ensure that you are using built-in version of `cut` and `add`; also check the output value after the `cut` to ensure it can be coerced to int w/o raising exception. I've just checked and found that even the Django 0.95 supports this usage:
def add(value, arg):
"Adds the arg to the value"
return int(value) + int(arg)
Problem
I want to use more than one filter on template like below: ``` value: {{ record.status|cut:"build:"|add:"5" }} ``` where record.status would be build:n, 0 < n< 100 but I want to add this value a base value 5. I tried above code, it only take effect on the first filter, so I did not get the value plus 5. Does django only support one filter? Thanks