{% load helpers %} {% with relationships=object.get_relationships_data %} {% if relationships.source or relationships.destination or relationships.peer %} {% for side, relationships in relationships.items %} {% for relationship, value in relationships.items %} {{ value.label }} {% if not value.has_many and value.value %} {{ value.value }} {% elif value.has_many and value.queryset.count %} {{ value.queryset.count }} {% if value.queryset.count > 1 %} {{ value.peer_type.model_class|meta:"verbose_name_plural" }} {% else %} {{ value.peer_type.model_class|meta:"verbose_name" }} {% endif %} {% else %} {% endif %} {% endfor %} {% endfor %} {% endif %} {% endwith %}