admin¶
Module: espressodb.base.admin
|
Extension to regular |
|
List view admin which displays all model fields. |
|
Tries to load all models from this app and registers |
Helper classes for setting up an admin page on start
-
class
BaseAdmin
(model, admin_site)[source]¶ Extension to regular
admin.ModelAdmin
which storesuser
as request logged in user on default.
-
class
ListViewAdmin
(model, admin_site, **kwargs)[source]¶ List view admin which displays all model fields.
-
search_fields
¶ The fields which are searchable on the admin page. Does only render fields which are present in
list_display
-
list_display
¶ The fields to display as a column on the admin page. Defaults to
["id", "instance_name", ..., "tag"]
where...
are the model default fields.
-
list_display_links
¶ The fields which will be a link to the detail view. Defaults to
["instance_name"]
or["id"]
or the first field inlist_display
(if the previous option are not present inlist_display
).
-
\*\*kwargs
Kwargs for the parent init.
-
-
register_admins
(app_name, exclude_models=None, admin_class=None)[source]¶ Tries to load all models from this app and registers
ListViewAdmin
sites.- Parameters
app_name (
str
) – The name of the app.exclude_models (
Optional
[List
[str
]]) – Models contained in this app which should not appear on the admin page. Uses the class name of the model.admin_class (
Optional
[ModelAdmin
]) – The admin model used to render the admin page. Defaults toListViewAdmin
.
Calls
admin.site.register()
for all models within the specified app.