//! Generated by `rustio-admin startapp {{name}}`. Customise freely.
{{imports}}
// `#[derive(RustioAdmin)]` generates the admin metadata AND the
// `impl Model` ORM glue (COLUMNS, row decoder, insert binder) from these
// fields — there is no hand-written code to keep in sync with the
// struct. `#[rustio(table = "…")]` pins the SQL table to the one this
// app's migration creates. Run `cargo expand` to see what is generated.
#[derive(RustioAdmin)]
#[rustio(table = "{{table}}")]
pub struct {{Singular}} {
pub id: i64,
{{struct_fields}}
}
// The `ModelAdmin` impl below customises the admin list / form
// surface for `{{Singular}}`. Every method has a sensible default;
// these starter overrides reflect the fields you declared with
// `--field` at scaffold time. Edit freely.
impl ModelAdmin for {{Singular}} {
/// Columns shown in the list-page table. Order matches the
/// `--field` declaration order.
fn list_display() -> &'static [&'static str] {
&[{{list_display_literal}}]
}
/// Columns whose `=` value is filterable via `?filter_<col>=<v>`
/// chips above the list page. Strings, enums, and small-cardinality
/// columns make the most sense here.
fn list_filter() -> &'static [&'static str] {
// Example: filter the list by a status enum.
// &["status"]
&[]
}
/// Columns that the list-page `?q=...` search box matches with
/// `ILIKE`. Defaulted to the text-shaped fields you declared
/// (`str` / `text`); leave empty if none.
fn search_fields() -> &'static [&'static str] {
&[{{search_fields_literal}}]
}
/// Default sort order. Prefix with `-` for descending.
fn ordering() -> &'static [&'static str] {
&["-id"]
}
}