Skip to content

Commit 0b56e65

Browse files
authored
feat: changeform before/after templates (#726)
1 parent 26f79a6 commit 0b56e65

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/unfold/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ class ModelAdmin(ModelAdminMixin, BaseModelAdmin):
235235
list_filter_submit = False
236236
list_fullwidth = False
237237
list_disable_select_all = False
238+
change_form_before_template = None
239+
change_form_after_template = None
238240
compressed_fields = False
239241
readonly_preprocess_fields = {}
240242
warn_unsaved_form = False

src/unfold/templates/admin/change_form.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}{% if form_url %}action="{{ form_url }}" {% endif %}method="post" id="{{ opts.model_name }}_form" {% if adminform.model_admin.warn_unsaved_form %}class="warn-unsaved-form"{% endif %} novalidate>
6565
{% csrf_token %}
6666

67+
{% if adminform.model_admin.change_form_before_template %}
68+
{% include adminform.model_admin.change_form_before_template %}
69+
{% endif %}
70+
6771
{% block form_top %}{% endblock %}
6872

6973
<div>
@@ -94,11 +98,14 @@
9498
{% for inline_admin_formset in inline_admin_formsets %}
9599
{% include inline_admin_formset.opts.template %}
96100
{% endfor %}
97-
98101
{% endblock %}
99102

100103
{% block after_related_objects %}{% endblock %}
101104

105+
{% if adminform.model_admin.change_form_after_template %}
106+
{% include adminform.model_admin.change_form_after_template %}
107+
{% endif %}
108+
102109
{% block submit_buttons_bottom %}{% submit_row %}{% endblock %}
103110

104111
{% block admin_change_form_document_ready %}

0 commit comments

Comments
 (0)