Contrib: SQLModel
Full attribute and method reference for the SQLModel backend (starlette_admin.contrib.sqlmodel),
generated from docstrings. SQLModel is SQLAlchemy underneath, so Admin and ModelView are thin
subclasses of the SQLAlchemy backend that validate form data through the model's
Pydantic layer. For a task-oriented walkthrough, see
SQLModel Integration.
starlette_admin.contrib.sqlmodel.admin.Admin
starlette_admin.contrib.sqlmodel.view.ModelView
Bases: ModelView
Source code in starlette_admin/contrib/sqlmodel/view.py
validate(request, data)
async
Validate form data against the SQLModel, excluding file and relation fields.
File and relation fields hold values (uploads, related objects) that the
Pydantic model itself cannot validate, so they are stripped from data
before calling model_validate.
Source code in starlette_admin/contrib/sqlmodel/view.py
starlette_admin.contrib.sqlmodel.view.InlineModelView
Bases: InlineModelView
Inline editing of SQLModel-backed related records inside a parent form.
Inherits FK detection and session logic from the SQLAlchemy
InlineModelView and adds SQLModel Pydantic validation on top.
Declare model as a class attribute (a SQLModel table class). fk_attr
is optional and is auto-detected from the parent's SQLAlchemy relationship
when omitted.
Example:
```python
class CommentInline(InlineModelView):
model = Comment
fields = ["id", "author", "body"]
extra = 1
class PostView(ModelView):
inlines = [CommentInline]
```