ErwinKomen / RU-asrbank

ASR transcription metadata repository
0 stars 0 forks source link

Re-order descriptor details form #9

Closed ErwinKomen closed 7 years ago

ErwinKomen commented 7 years ago

The Descriptor details form should be re-ordered such, that it reflects the specified order provided by Henk van den Heuvel.

ErwinKomen commented 7 years ago

It was difficult to find a good solution, but I found one description at https://linevi.ch/en/django-inline-in-fieldset.html.

Basically the steps are:

  1. Copy the django/contrib/admin/templates/admin/change_form.html to a directory [application_root]/templates/admin/[package]/[app_name]
  2. Copy the django/contrib/admin/templates/admin/includes/fieldset.html to a directory [application_root]/templates/admin/includes
  3. Optionally (if it is needed to modify the tabular template) copy django/contrib/admin/templates/admin/edit_inline/tabular.html to a directory [application_root]/templates/admin/edit_inline
  4. To each of the admin.TabularInline classes in admin.py add a line insert_after = 'name_of_field', where the name of the field after which the inline should come appears
  5. Modify part of change_form.html in this way:

{% block field_sets %} {% for fieldset in adminform %} {% include "admin/includes/fieldset.html" with inline_admin_formsets=inline_admin_formsets %} {% endfor %} {% endblock %} ` {% block after_field_sets %}{% endblock %} {% block inline_field_sets %} {% for inline_admin_formset in inline_admin_formsets %} {% if not inline_admin_formset.opts.insert_after %} {% include inline_admin_formset.opts.template %} {% endif %} {% endfor %} {% endblock %}`

Insert the following just preceding the penultimate endfor statement: {# Insert inlines after the field #} {% for inline_admin_formset in inline_admin_formsets %} {% if inline_admin_formset.opts.insert_after == field.field.name %} {% include inline_admin_formset.opts.template with subordinate_formset=subordinate_formset %} {% endif %} {% endfor %}