From 18ed48061933b1259445622a333d8284a290ccc8 Mon Sep 17 00:00:00 2001 From: Frankie Dintino Date: Sat, 13 Jul 2024 21:14:01 -0400 Subject: [PATCH] fix: stacked inline label and field alignment in django 4.2+ --- .../nesting/admin/includes/inline.html | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/nested_admin/templates/nesting/admin/includes/inline.html b/nested_admin/templates/nesting/admin/includes/inline.html index e454a96..604f7a1 100644 --- a/nested_admin/templates/nesting/admin/includes/inline.html +++ b/nested_admin/templates/nesting/admin/includes/inline.html @@ -1,3 +1,4 @@ +{% load nested_admin %}
{% if fieldset.name %}

{{ fieldset.name }}

{% endif %} {% if fieldset.description %} @@ -5,10 +6,14 @@ {% endif %} {% for line in fieldset %}
- {% if line.fields|length == 1 %}{{ line.errors }}{% endif %} + {% if line.fields|length == 1 %}{{ line.errors }}{% elif "4.2"|django_version_gte %}
{% endif %} {% for field in line %} -
- {% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %} + {% if "4.2"|django_version_gte %} +
+ {% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %} + {% endif %} +
+ {% if "4.2"|django_version_lt %}{% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %}{% endif %} {% if field.is_checkbox %} {{ field.field }}{{ field.label_tag }} {% else %} @@ -19,13 +24,15 @@ {{ field.field }} {% endif %} {% endif %} - {% if field.field.help_text %} -
- {{ field.field.help_text|safe }} -
- {% endif %}
+ {% if field.field.help_text %} +
+ {{ field.field.help_text|safe }} +
+ {% endif %} + {% if "4.2"|django_version_gte %}
{% endif %} {% endfor %} + {% if "4.2"|django_version_gte %}{% if not line.fields|length == 1 %}
{% endif %}{% endif %}
{% endfor %}