Base view
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)
Source code in sqladmin/models.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
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.