Source

django-committees / committees / admin.py

from django.contrib import admin
from django.core.urlresolvers import reverse

from committees.models import Committee, CommitteeMember, CommitteeType


class CommitteeTypeAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug', 'order',)
    search_fields = ('name',)
    prepopulated_fields = {'slug': ('name',)}
admin.site.register(CommitteeType, CommitteeTypeAdmin)


class CommitteeMemberAdmin(admin.TabularInline):
    model = CommitteeMember
    raw_id_fields = ('contact',)


class CommitteeAdmin(admin.ModelAdmin):
    inlines = (CommitteeMemberAdmin,)
    list_display = ('name', 'slug', 'type')
    list_filter = ('type',)
    prepopulated_fields = {'slug': ('name',)}
    search_fields = (
        'name',
        'members__first_name',
        'members__last_name',
        'members__email',
    )
    ordering = ('name',)
admin.site.register(Committee, CommitteeAdmin)