Slide 5
Slide 5 text
ModelAdmin (cont’d.)
• More ModelAdmin attributes:
• fieldsets: allows customized grouping of different fields on the Model
change form
• list_filter: a list or tuple of fields that are used as filters to show only
certain objects
• search_fields: a list or tuple of fields (extending into related objects)
that should be searched to show only objects with matching values
5
class FlatPageAdmin(admin.ModelAdmin):
fieldsets = (
(None, {
'fields': ('url', 'title', 'content', 'sites')
}),
('Advanced options', {
'classes': ('collapse',),
'fields': ('enable_comments', 'registration_required', 'template_name')
}),
)
class PlayerAdmin(admin.ModelAdmin):
list_display = ('name', 'number', 'team', )
search_fields = ('name', 'number', 'team__name', )
list_filter = ('team', )