Inlines

Admin inline customizations

Collapsing inlines

With yawd-admin you can collapse your inlines, like you do with your fieldsets. Collapsing an admin inline is easy and works for both stacked and tabular inlines:

class MyStackedInline(admin.StackedInline):
        ...
        collapse = True

class MyTabularInline(admin.TabularInline):
        ...
        collapse = True

Inline description

When setting a model’s fieldsets you can provide a description key to specify a text that will be displayed under the fieldset header. Now you can achieve the same effect with your inlines using the description member in your Inline class:

class MyStackedInline(admin.StackedInline):
        ...
        description = 'My inline description text'

New inline types

In addition to the stacked and tabular inlines, yawd-admin implements a couple of new inline types.

One-to-one inlines

If you have one-to-one relations, you might want to use the OneToOneInline class to make the add/change page look like that of a single model.

For example, say you’re developing an e-shop selling books. In your admin.py:

from yawdadmin.admin import OneToOneInline

class BookInlineAdmin(OneToOneIneline):
        model = Book
        #by default show_title is True
        #disable show_title if you want to to hide the model verbose name
        #and use it in conjuction with fieldsets to achieve the desired effect
        show_title = False

class ProductAdmin(admin.ModelAdmin):
        inlines = (BookInline,)
        ....

admin_site.register(Product, ProductAdmin)

That way the Product admin pages will look like a single form is being used.