{% for coauthor in story.coauthors|sort(attribute='id') %} {%- set author = coauthor.author -%} {% if loop.first %} {{author.username}} {% if loop.length > 1 %}(в соавторстве с{% endif %} {% endif %} {% if not loop.first %} {{author.username}}{% if loop.revindex0 == 1 %} и {% endif %}{% if loop.revindex0 > 1 %}, {% endif %}{% if loop.last and loop.length > 1 %}){% endif %} {% endif %} {% endfor %}