This is a small app for creating nice inlines in django admin:
You may install it via pip
or clone all repository:
pip install git+https://github.com/DjangoAdminHackers/selective-inline.git
Also you need to add selinline
to your INSTALLED_APPS
list
The app provides one more inline class which supports all admin inline options and more.
So admin.py example file:
from django.contrib import admin
from django.contrib.admin.options import InlineModelAdmin
from selinline.admin import SelectiveInlineMixin
from .models import Author, Book
class BookAdminInline(SelectiveInlineMixin, InlineModelAdmin):
orderable_field = 'order_num' # this option is required only for "ordering" feature
model = Book
extra = 1
class AuthorAdmin(admin.ModelAdmin):
inlines = (BookAdminInline, )
admin.site.register(Author, AuthorAdmin)
You may check out complete test project in the "example" project folder
django-selective-inlines
supports ordering inline records via drag-n-drop. For that you need to have some integer
field in your model for storing order number value. So just set orderable_field
property equals to that field name
inside your inline class like in example above and that's it.