Skip to content

BaseView

sqladmin.models.BaseView

Bases: BaseModelView

Base class for defining admnistrative views for the model.

Usage
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: str = '' class-attribute

Name of the view to be displayed.

identity: str = '' class-attribute

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

methods: List[str] = ['GET'] class-attribute

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

icon: str = '' class-attribute

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

include_in_schema: bool = True class-attribute

Control whether this endpoint should be included in the schema.