I am trying to create a filter with multiple parameters. I found the first answer of this link is useful, so took his idea.
However, I don't know how to create a string variable containing all values. Here is my code:
{% with amount_comments|to_string+","+limit_amount_comments|to_string as args %}
{% if page_nr|page_not_over_amount:args %}
<a href="{% url 'post:detail' topic.id page_nr|increase:1 %}">Next Page</a>
{% endif %}
{% endwith %}
and this is to_string filter:
@register.filter(name='to_string')
def to_string(value):
return str(value)
then page_not_over_amount filter using that args:
@register.filter(name='page_not_over_amount')
def page_not_over_amount(page_nr, args):
if args is None:
return False
else:
arg_list = [arg.strip() for arg in args.split(',')]
comment_amount = arg_list[0]
comment_limit = arg_list[1]
if page_nr*comment_limit < comment_amount-comment_limit:
return True
else:
return False
But I get this exception:
Could not parse some characters: amount_comments|to_string|+","+limit_amount_comments||to_string
Thanks in advance!