From af54842fbc6501d87db7dafc96bf46e3c348f1da Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Sun, 12 Apr 2020 01:08:49 +0200 Subject: [PATCH] Fix: Ordered Items not rendered in Django admin This bus has been reported here: https://github.com/awesto/cookiecutter-django-shop/issues/27 --- .../shop/admin/edit_inline/stacked-order.html | 27 ++++++++----------- .../shop/admin/includes/fieldset.html | 12 ++++----- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/shop/templates/shop/admin/edit_inline/stacked-order.html b/shop/templates/shop/admin/edit_inline/stacked-order.html index 8fd51d478..37a8d00b9 100644 --- a/shop/templates/shop/admin/edit_inline/stacked-order.html +++ b/shop/templates/shop/admin/edit_inline/stacked-order.html @@ -1,30 +1,25 @@ -{% load i18n admin_urls admin_static %} -
+{% load i18n admin_urls static %} +
+

{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}

{{ inline_admin_formset.formset.management_form }} {{ inline_admin_formset.formset.non_form_errors }} -{% for inline_admin_form in inline_admin_formset %}
-

{{ inline_admin_formset.opts.verbose_name|capfirst }}: {% if inline_admin_form.original %}{{ inline_admin_form.original }}{% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %} {% trans "Change" %}{% endif %} +{% for inline_admin_form in inline_admin_formset %}
+

{{ inline_admin_formset.opts.verbose_name|capfirst }}: {% if inline_admin_form.original %}{{ inline_admin_form.original }}{% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %} {% if inline_admin_formset.has_change_permission %}{% trans "Change" %}{% else %}{% trans "View" %}{% endif %}{% endif %} {% else %}#{{ forloop.counter }}{% endif %} {% if inline_admin_form.show_url %}{% trans "View on site" %}{% endif %} - {% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}{% endif %} + {% if inline_admin_formset.formset.can_delete and inline_admin_formset.has_delete_permission and inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}{% endif %}

{% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %} {% for fieldset in inline_admin_form %} {% include "shop/admin/includes/fieldset.html" %} {% endfor %} {% if inline_admin_form.needs_explicit_pk_field %}{{ inline_admin_form.pk_field.field }}{% endif %} - {{ inline_admin_form.fk_field.field }} + {% if inline_admin_form.fk_field %}{{ inline_admin_form.fk_field.field }}{% endif %}
{% endfor %} +

- - diff --git a/shop/templates/shop/admin/includes/fieldset.html b/shop/templates/shop/admin/includes/fieldset.html index 836854cc6..941587200 100644 --- a/shop/templates/shop/admin/includes/fieldset.html +++ b/shop/templates/shop/admin/includes/fieldset.html @@ -7,30 +7,28 @@
{% if line.fields|length_is:'1' %}{{ line.errors }}{% endif %} {% for field in line %} - + {% if not line.fields|length_is:'1' and not field.is_readonly %}{{ field.errors }}{% endif %} {% if field.is_checkbox %} {{ field.field }}{{ field.label_tag }} {% elif field.field.name|truncatechars:18 == 'render_as_html_...' %} {{ field.label_tag }} - {% with field.contents as contents %} - {% if contents %} + {% with field.contents as contents %}{% if contents %}

 

{{ contents }} {% else %}

- {% endif %} - {% endwith %} + {% endif %}{% endwith %} {% else %} {{ field.label_tag }} {% if field.is_readonly %} -

{{ field.contents }}

+
{{ field.contents }}
{% else %} {{ field.field }} {% endif %} {% endif %} {% if field.field.help_text %} -

{{ field.field.help_text|safe }}

+
{{ field.field.help_text|safe }}
{% endif %}
{% endfor %}