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§
Sourcefn model_name(&self) -> &str
fn model_name(&self) -> &str
Get the model name
Provided Methods§
Sourcefn table_name(&self) -> &str
fn table_name(&self) -> &str
Get the database table name
By default, returns the model name in lowercase.
Sourcefn list_display(&self) -> Vec<&str>
fn list_display(&self) -> Vec<&str>
Fields to display in list view
Sourcefn list_filter(&self) -> Vec<&str>
fn list_filter(&self) -> Vec<&str>
Fields that can be used for filtering
Sourcefn search_fields(&self) -> Vec<&str>
fn search_fields(&self) -> Vec<&str>
Fields that can be searched
Sourcefn readonly_fields(&self) -> Vec<&str>
fn readonly_fields(&self) -> Vec<&str>
Read-only fields
Sourcefn list_per_page(&self) -> Option<usize>
fn list_per_page(&self) -> Option<usize>
Number of items per page (None = use site default)
Sourcefn 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_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.
Sourcefn 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_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.
Sourcefn 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_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.
Sourcefn 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,
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.