Skip to main content

ModelAdmin

Trait ModelAdmin 

Source
pub trait ModelAdmin: AdminModel {
    // Provided methods
    fn list_display() -> &'static [&'static str] { ... }
    fn list_filter() -> &'static [&'static str] { ... }
    fn search_fields() -> &'static [&'static str] { ... }
    fn ordering() -> &'static [&'static str] { ... }
    fn list_per_page() -> usize { ... }
    fn readonly_fields() -> &'static [&'static str] { ... }
    fn fieldsets() -> &'static [Fieldset] { ... }
}
Expand description

Django-style customisation surface for a registered admin model.

Every type that implements AdminModel gets a default impl via the blanket below. Override the methods you care about; everything else inherits sensible defaults.

Provided Methods§

Source

fn list_display() -> &'static [&'static str]

Columns shown on the list page, in order. Default: every field declared on AdminModel::FIELDS.

Returning &[] means “use the model’s full field list” — the list page expands the empty default into M::FIELDS. Any non-empty slice replaces the defaults verbatim.

Source

fn list_filter() -> &'static [&'static str]

Columns offered as filter chips in the sidebar. Default: none.

Source

fn search_fields() -> &'static [&'static str]

Columns searched by the list-page search box (case-insensitive substring match). Default: none.

Source

fn ordering() -> &'static [&'static str]

Default ordering. -foo for foo DESC, foo for foo ASC. Multiple entries → multi-column ORDER BY in slice order. Default: ["-id"] (newest first).

Source

fn list_per_page() -> usize

Rows per page on the list view. Default: 50.

Source

fn readonly_fields() -> &'static [&'static str]

Read-only fields on the change form. Default: none.

Source

fn fieldsets() -> &'static [Fieldset]

Field grouping on the change form. Default: empty — fall back to the framework heuristic (Default / System / Advanced).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§