Skip to content

BaseView

sqladmin.models.BaseView

Bases: BaseModelView

Base class for defining admnistrative views for the model.

Usage

```python from sqladmin import BaseView, expose

class CustomAdmin(BaseView): name = "Custom Page" icon = "fa-solid fa-chart-line"

@expose("/custom", methods=["GET"])
async def test_page(self, request: Request):
    return await self.templates.TemplateResponse(request, "custom.html")

admin.add_base_view(CustomAdmin) ```

name = '' class-attribute

Name of the view to be displayed.

identity = '' class-attribute

Same as name but it will be used for URL of the endpoints.

methods = ['GET'] class-attribute

List of method names for the endpoint. By default it's set to ["GET"] only.

icon = '' class-attribute

Display icon for ModelAdmin in the sidebar. Currently only supports FontAwesome and Tabler icons.

include_in_schema = True class-attribute

Control whether this endpoint should be included in the schema.