{% load relations %}
{% load generic %}
{% load core %}
{% relations_from from_obj=object as relations %}
{% possible_relation_types_from object as possible_relations %}
{% get_relation_targets_from object as possible_targets %}

{% block display-relations %}
  {% for target in possible_targets %}
    <div class="card mb-2">
      <div class="card-header">{{ target.name }}</div>
      {% with object.id|stringformat:"i" as object_id %}
        {% with "rel_"|add:object_id|add:"_"|add:target.name as replace_id %}
          {% with target|model_meta:"object_name" as table_suffix %}
            {% get_relation_between_content_types object.content_type target as relation_types %}
            {% relations_instances_from_relation_types relation_types as relations %}
            <div class="card-body">
              {% include "relations/partials/list_relations.html" %}
              {% if linkify %}
                {% natural_keys_by_content_types relation_types as relation_types_natural_keys %}
                {% for relation_type in relation_types %}
                  {% include "relations/partials/create_relation_link.html" with relation_types=relation_types_natural_keys|join:"," %}
                {% endfor %}
              {% endif %}
            </div>
          {% endwith %}
        {% endwith %}
      {% endwith %}
    </div>
  {% endfor %}
{% endblock display-relations %}
