Skip to main content

django-admin-fieldsets-extra

Build status PyPI version PyPI - Python Version PyPI - Django Version Downloads

Extras for Django admin fieldsets:

  • Interleave fieldsets and inlines in the change form: put an inline right after the fields it belongs with, instead of always at the bottom.
  • Save a fieldset on its own with a "Save Contact" button, without submitting or reloading the rest of the page.

Books inline between the name and the contact fieldset, articles before the biography

  • One ordered list replaces fieldsets + inlines (with or without inlines in it).
  • No copy of Django's change_form.html: it only overrides its field_sets / inline_field_sets blocks, so it follows your Django version.
  • Nothing changes in the inlines' DOM: Django's inline JS ("Add another", autocomplete, date pickers…) and inline templates work as usual.

Install

pip install django-admin-fieldsets-extra

Add to INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "django_admin_fieldsets_extra",
]

Usage

from django.contrib import admin

from django_admin_fieldsets_extra.mixins import FieldsetsExtraMixin


class BookInline(admin.TabularInline):
    model = Book


class ArticleInline(admin.StackedInline):
    model = Article


@admin.register(Author)
class AuthorAdmin(FieldsetsExtraMixin, admin.ModelAdmin):
    fieldsets_with_inlines = [
        (None, {"fields": ["name"]}),
        BookInline,
        ("Contact", {"fields": ["email", "phone"], "save_button": True}),
        ArticleInline,
        ("Biography", {"fields": ["bio"], "classes": ["collapse"]}),
    ]

Each entry is either a fieldset, exactly as in ModelAdmin.fieldsets, or an inline class, as in ModelAdmin.inlines. They are rendered in that order.

  • fieldsets and inlines are derived from it (in their relative order), so Django's admin checks and every hook that reads them keep working. Don't set them as well (admin_fieldsets_extra.E003).
  • Dynamic layouts: override get_fieldsets_with_inlines(request, obj=None); get_fieldsets() and get_inlines() follow it. Static fieldsets / inlines would be ignored then (admin_fieldsets_extra.W001 warns about it).
  • Permissions: an inline the user can't see is simply left out, as in the regular change form.
  • Anything not in the layout (e.g. extra fieldsets or inlines from your own get_fieldsets() / get_inlines()) is rendered after it.
  • Without fieldsets_with_inlines, the mixin does nothing: the regular change form.

Saving a fieldset

Add "save_button": True to a fieldset of the layout to give it a "Save Contact" button (named after the fieldset; "Save" if it has no name) that saves only its fields:

(("Contact", {"fields": ["email", "phone"], "save_button": True}),)

A fieldset with its own save button, after saving

save_button is an option of this package: it is removed before the fieldset reaches Django (whose Fieldset rejects unknown options), so AuthorAdmin.fieldsets and get_fieldsets() never contain it.

How it works

  • The button is rendered by the server under the fieldset, only on existing objects and for users with change permission. It is hidden while the fieldset is collapsed.
  • Only the fields inside that fieldset are sent (files included), to <object_id>/fieldsets/<n>/save/, n being its position in get_fieldsets().
  • The server builds get_form(request, obj, fields=<its editable fields>) on the object as stored in the database, validates it, calls save_form(), save_model() and form.save_m2m() in a transaction, and records the change in the history ("Changed Email and Phone."; nothing if nothing changed).
  • The fieldset is re-rendered and swapped in place: field errors on their fields, form-wide errors (from clean()) above the fieldset, "Saved." next to the button on success. The rest of the page (other fieldsets, inlines, unsaved edits) is left untouched. A fieldsets-extra:saved event bubbles from the new fieldset.

Caveats

  1. Validation: only this fieldset's fields are validated as fields, but Model.clean() / ModelForm.clean() still run, with the other fields' stored values. A rule that combines fields of two fieldsets sees the saved value of the other one, not what is unsaved on screen.
  2. save_model(request, obj, form, change) gets a form with only these fields. If you override it and read other fields from form.cleaned_data, it won't work from this button. save_related() and the inlines' formsets are not called.
  3. Concurrency: the object is re-read from the database right before saving, so the page's (possibly stale) values of other fields are never written back. As with the regular Save button, two people changing the same field at the same time: the last save wins.
  4. Read-only fields are never saved; a fieldset with only read-only fields has no button (the endpoint answers 404).

The buttons' script and style load only where a fieldset of the layout has "save_button": True or "autosave": True (or the layout is decided per request, by get_fieldsets_with_inlines()).

A fieldset that saves itself

Add "autosave": True instead, and the fieldset saves itself as its fields change, without a button: a checkbox or a select at once, a text when it's left or on Enter (which then doesn't submit the page). One field alone in a fieldset is a field that saves itself:

("Status", {"fields": ["active", "notes"], "autosave": True}),

A fieldset that saves itself, just saved

It saves as the button does (the same endpoint, the same validation, permissions, save_model(), history and caveats), and also:

  • What someone else changed meanwhile isn't overwritten. The page sends what the fieldset had when it loaded (or last saved); if what's stored differs, in any of its fields, nothing is saved: the fieldset shows what's saved now, saying so.
  • The fieldset being edited stays as it is (its focus, what's being written): only "Saving…" and "Saved" change under it. Not being edited, it's re-rendered with what was saved. With errors, it's re-rendered with them, the focus where it was.
  • One request at a time per fieldset; what changes meanwhile goes after it.
  • With everything editable saving itself (every fieldset with editable fields, and no inlines), the page's "Save" buttons aren't shown; "Delete" and "History" are. Adding an object, there's nothing to save itself yet: the page saves as always.
  • Not on Unfold's tabs (check E101), as the button.

FieldsetsExtraMixin is two mixins: FieldsetsLayoutMixin (inlines between fieldsets) and FieldsetSaveMixin (the save buttons and autosave, over the layout). Use the first alone for a layout without them.

Customizing the template

The mixin sets change_form_template to admin/fieldsets_extra/change_form.html, which extends admin/change_form.html. For your own change form template, extend this one instead:

{% extends "admin/fieldsets_extra/change_form.html" %}

{% block layout_inline %}
  <div class="my-inline">{{ block.super }}</div>
{% endblock %}
Block Contains
field_sets The whole layout (falls back to Django's when there is none).
layout_fieldset One fieldset (fieldset, and item.index, its position in get_fieldsets()); includes admin/fieldsets_extra/includes/fieldset.html.
layout_inline One inline (inline_admin_formset).
inline_field_sets Empty when there is a layout (the inlines are already rendered).

admin/fieldsets_extra/includes/fieldset.html renders one fieldset and, if it has one, its save button. Its blocks: non_field_errors, fieldset, save_bar and save_label. It is also the save endpoint's response (fieldset_response.html, block response; set fieldset_save_response_template on the ModelAdmin to use another one). The JS replaces the fieldset-with-save container by its id and relies on the data-fieldset-save-url attribute and the data-fieldset-save button: keep them when overriding blocks.

The layout is also in the context as fieldsets_with_inlines: a list of items with is_inline, fieldset, index, inline_admin_formset, save_url and save_label. get_layout_items() builds it, if you need to change how the layout is matched to the form.

Themes

System checks

Misconfigurations are reported by manage.py check (and at startup). The full list of IDs is in docs/system-checks.md.

Translations

Ships a Spanish (es) translation: the save buttons, their tooltips and the status messages follow the admin's active language.

Demo

cd example
python manage.py migrate
python manage.py seed_demo      # admin/admin + an author with books
python manage.py runserver

Compatibility

Django 4.2 – 6.1, Python 3.10+.

License

MIT

Metadata

Release files for django-admin-fieldsets-extra 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-admin-fieldsets-extra 0.1.2
File Size Uploaded Provenance Actions
django_admin_fieldsets_extra-0.1.2.tar.gz 387.0 kB With provenance Details for django_admin_fieldsets_extra-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-admin-fieldsets-extra 0.1.2
File Interpreter ABI Platform Actions
django_admin_fieldsets_extra-0.1.2-py3-none-any.whl Python 3 none any Details for django_admin_fieldsets_extra-0.1.2-py3-none-any.whl

Total release size: 413.6 kB

Release files / django_admin_fieldsets_extra-0.1.2.tar.gz

Download URL django_admin_fieldsets_extra-0.1.2.tar.gz
Size 387.0 kB
Tags Source
SHA-256 checksum
How to use checksums
defb0d667305c0fc2fd4a8c9003227e038164478d76fb447bea9ad2438511125
BLAKE2b-256 checksum
How to use checksums
e0150d9d033edaa8fff82f6ca8992c81a05ae0db1891b9602c176cfc63ceaa84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / django_admin_fieldsets_extra-0.1.2-py3-none-any.whl

Download URL django_admin_fieldsets_extra-0.1.2-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db7da9b73aa433efc8b2236d2ed5d9d7f9124a451c94cd64cd0a096d42797dcb
BLAKE2b-256 checksum
How to use checksums
58717b1fac663943fc02d1c36e44de4cd3e482181073c033c771ae79f6c16090
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for django-admin-fieldsets-extra 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_admin_fieldsets_extra-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page