Skip to main content

A Django Admin extension that allows you to mix and reorder multiple inline classes together

Project description

Build Status Coverage Status PyPI version

Merged Inlines

Merged Inlines is a Django App that allows you to merge multiple inline models into a single form. This is particularly useful if you need to mix the orderings of multiple authors together, so your inlines in the Admin panel can look like:

  • inline for Poem 1

  • inline for Poem 2

  • inline for Book 1

  • inline for Poem 3

  • inline for Book 2

Instead of:

  • inline for Poem 1

  • inline for Poem 2

  • inline for Poem 3

  • inline for Book 1

  • inline for Book 2


Install using pip:

pip install django-merged-inlines

Quick start

  1. Add “merged_inlines” to your INSTALLED_APPS setting:

  1. In the file for the app you’re adding merged inlines to, add:

from merged_inlines.admin import MergedInlineAdmin
  1. Instead of admin.ModelAdmin, make your Admin class a child of MergedInlineAdmin, and add your inline classes as you normally would:

class MyFirstInline(admin.TabularInline):

class MySecondInline(admin.TabularInline):

class MyModelAdmin(MergedInlineAdmin):
    inlines = [MyFirstInline,MySecondInline],MyModelAdmin)

Note that regardless of the Inline class used (TabularInline or StackedInline), Merged Inlines currently only renders as a tabular inline.



You can use merged_field_order in your MergedInlineAdmin class to set the order of the fields. The list/type must contain all of fields that will be editable in the admin: to exclude fields from the formset, use the builtin ModelAdmin exclude function.

class MyInline(admin.TabularInline):
    exclude = ('my_unwanted_field')

class MyModelAdmin(MergedInlineAdmin):
    inlines = [MyInline]

    merged_field_order = ('put_this_field_first','followed_by_this_field','and_then_this_one')


This option determines what field will be used to sort your merged inline models. The shared models must both have the shared field, otherwise an Exception will be raised. If no field is specified, id will be used.

class BookInline(admin.TabularInline):
    model = Book

class PoemInline(admin.TabularInline):
    model = Poem

class AuthorAdmin(MergedInlineAdmin):
    merged_inline_order = 'year'

Version History

  • 1.0 - Added full test coverage. Moved to Django 1.7+ compatibility, dropped compatibility with Django <1.7.

  • 0.2 - Fixed ID ordering and js issues, thanks to @kotyy

  • 0.1 - Initial release

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-merged-inlines-1.0.3.tar.gz (11.1 kB view hashes)

Uploaded Source

Built Distribution

django_merged_inlines-1.0.3-py3-none-any.whl (13.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page