Skip to main content

ModelAdmin

Trait ModelAdmin 

Source
pub trait ModelAdmin: Send + Sync {
Show 14 methods // Required method fn model_name(&self) -> &str; // Provided methods fn table_name(&self) -> &str { ... } fn pk_field(&self) -> &str { ... } fn list_display(&self) -> Vec<&str> { ... } fn list_filter(&self) -> Vec<&str> { ... } fn search_fields(&self) -> Vec<&str> { ... } fn fields(&self) -> Option<Vec<&str>> { ... } fn readonly_fields(&self) -> Vec<&str> { ... } fn ordering(&self) -> Vec<&str> { ... } fn list_per_page(&self) -> Option<usize> { ... } fn has_view_permission<'life0, 'life1, 'async_trait>( &'life0 self, _user: &'life1 (dyn Any + Send + Sync), ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn has_add_permission<'life0, 'life1, 'async_trait>( &'life0 self, _user: &'life1 (dyn Any + Send + Sync), ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn has_change_permission<'life0, 'life1, 'async_trait>( &'life0 self, _user: &'life1 (dyn Any + Send + Sync), ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn has_delete_permission<'life0, 'life1, 'async_trait>( &'life0 self, _user: &'life1 (dyn Any + Send + Sync), ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... }
}
Expand description

Trait for configuring model administration

Implement this trait to customize how a model is displayed and edited in the admin.

Required Methods§

Source

fn model_name(&self) -> &str

Get the model name

Provided Methods§

Source

fn table_name(&self) -> &str

Get the database table name

By default, returns the model name in lowercase.

Source

fn pk_field(&self) -> &str

Get the primary key field name

By default, returns “id”.

Source

fn list_display(&self) -> Vec<&str>

Fields to display in list view

Source

fn list_filter(&self) -> Vec<&str>

Fields that can be used for filtering

Source

fn search_fields(&self) -> Vec<&str>

Fields that can be searched

Source

fn fields(&self) -> Option<Vec<&str>>

Fields to display in forms (None = all fields)

Source

fn readonly_fields(&self) -> Vec<&str>

Read-only fields

Source

fn ordering(&self) -> Vec<&str>

Ordering for list view (prefix with “-” for descending)

Source

fn list_per_page(&self) -> Option<usize>

Number of items per page (None = use site default)

Source

fn has_view_permission<'life0, 'life1, 'async_trait>( &'life0 self, _user: &'life1 (dyn Any + Send + Sync), ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if user has permission to view this model

Default implementation allows all access. Override this method to implement custom permission checking.

Source

fn has_add_permission<'life0, 'life1, 'async_trait>( &'life0 self, _user: &'life1 (dyn Any + Send + Sync), ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if user has permission to add instances

Default implementation allows all access. Override this method to implement custom permission checking.

Source

fn has_change_permission<'life0, 'life1, 'async_trait>( &'life0 self, _user: &'life1 (dyn Any + Send + Sync), ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if user has permission to change instances

Default implementation allows all access. Override this method to implement custom permission checking.

Source

fn has_delete_permission<'life0, 'life1, 'async_trait>( &'life0 self, _user: &'life1 (dyn Any + Send + Sync), ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if user has permission to delete instances

Default implementation allows all access. Override this method to implement custom permission checking.

Implementors§