Skip to content

Commit

Permalink
use zip for iterating over the formatted values (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
okapies committed Jun 23, 2022
1 parent 95e40ca commit 6552759
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions sqladmin/application.py
Expand Up @@ -52,6 +52,7 @@ def __init__(
]
)
self.templates.env.globals["min"] = min
self.templates.env.globals["zip"] = zip
self.templates.env.globals["admin_title"] = title
self.templates.env.globals["admin_logo_url"] = logo_url
self.templates.env.globals["model_admins"] = self.model_admins
Expand Down
4 changes: 2 additions & 2 deletions sqladmin/templates/details.html
Expand Up @@ -22,8 +22,8 @@ <h3 class="card-title">{{ model_admin.pk_column.name }}: {{ model_admin.get_attr
{% if (name, attr) in model_admin._details_relations %}
{% if is_iterable( value ) %}
<td>
{% for elem in value %}
<a href="{{ model_admin._url_for_details(elem) }}">({{ formatted_value[loop.index0] }})</a>
{% for elem, formatted_elem in zip(value, formatted_value) %}
<a href="{{ model_admin._url_for_details(elem) }}">({{ formatted_elem }})</a>
{% endfor %}
</td>
{% else %}
Expand Down
4 changes: 2 additions & 2 deletions sqladmin/templates/list.html
Expand Up @@ -110,8 +110,8 @@ <h3 class="card-title">{{ model_admin.name_plural }}</h3>
{% if (name, column) in model_admin._list_relations %}
{% if is_iterable( value ) %}
<td>
{% for elem in value %}
<a href="{{ model_admin._url_for_details(elem) }}">({{ formatted_value[loop.index0] }})</a>
{% for elem, formatted_elem in zip(value, formatted_value) %}
<a href="{{ model_admin._url_for_details(elem) }}">({{ formatted_elem }})</a>
{% endfor %}
</td>
{% else %}
Expand Down

0 comments on commit 6552759

Please sign in to comment.