View generators
View generators decide what each screen contains: which fields, in which boxes, with which actions.
Without them a resource still gets all four views with every field in a plain stack. Add a generator when a view needs a different set of fields or a real layout.
from habarico import ModelAdmin
from habarico.schema.generators import (
CreateViewSchemaGenerator,
EditViewSchemaGenerator,
ListViewSchemaGenerator,
ShowViewSchemaGenerator,
)
from .models import Product
class ProductAdmin(ModelAdmin):
model = Product
view_schema_generators = [
ListViewSchemaGenerator(),
CreateViewSchemaGenerator(),
EditViewSchemaGenerator(),
ShowViewSchemaGenerator(),
]
Removing a generator removes the view: no schema, no route, no button pointing at it.
Pages
| Page | What it covers |
|---|---|
| List view schema generators | Columns, filters, sorting, row and toolbar actions |
| Form schema generators | Create, edit and show layouts — boxes, tabs, wizards |
| Action view schema generator | Views for non-CRUD actions |
| Field descriptor reference | Every option a Field accepts, and where it lands in the schema |
| Box reference | Every box type and its parameters |
Permissions come first
A generator never widens what DRF allows. If the underlying view rejects the request, the schema is not produced and the frontend has nothing to render — which is why hiding a button is never the mechanism that protects an operation.
See also
- View components — what renders these schemas
- Layout components — the boxes a form generator arranges
- Permissions — the layer that decides availability