{% load custom_tags_and_filters %} {% with order_list=order_by|concat:',-'|concat:order_by %} {# order_list = "name,-name #} {% with order=page.paginator.order_by|cut:order_by|yesno:order_list %} {# order = -name if order_by is name and vice versa #} {{ name }} {% endwith %} {% endwith %}