Rustango docs

Add a custom admin bulk action

Problem

Editors need a one-click "Publish selected" button in the admin list view.

Register a bulk action; it receives the selected primary keys and runs your closure inside a transaction.

register_admin_action!(Article, "publish", "Publish selected", |pool, ids| async move {
    Article::objects()
        .filter(Article::id.is_in(ids))
        .update_pool(&pool, &[("status", "published")])
        .await?;
    Ok(())
});

Permissions

Actions respect the same per-model permission codenames the admin uses — only users with article.change see the button.