Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
2b0c9e45
Commit
2b0c9e45
authored
Oct 16, 2018
by
PJ Janse van Rensburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expand documentation: grouping views and adding links to the menu.
parent
18e0d317
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
7 deletions
+26
-7
introduction.rst
doc/introduction.rst
+25
-6
base.py
flask_admin/model/base.py
+1
-1
No files found.
doc/introduction.rst
View file @
2b0c9e45
...
@@ -156,12 +156,9 @@ Customizing Built-in Views
...
@@ -156,12 +156,9 @@ Customizing Built-in Views
****
****
The built-in `ModelView` class is great for getting started quickly. But, you'll want
When inheriting from `ModelView`, values can be specified for numerous
to configure its functionality to suit your particular models. This is done by setting
configuration parameters. Use these to customize the views to suit your
values for the configuration attributes that are made available in the `ModelView` class.
particular models::
To specify some global configuration parameters, you can subclass `ModelView` and use that
subclass when adding your models to the interface::
from flask_admin.contrib.sqla import ModelView
from flask_admin.contrib.sqla import ModelView
...
@@ -287,6 +284,28 @@ To **enable csv export** of the model view::
...
@@ -287,6 +284,28 @@ To **enable csv export** of the model view::
This will add a button to the model view that exports records, truncating at :attr:`~flask_admin.model.BaseModelView.export_max_rows`.
This will add a button to the model view that exports records, truncating at :attr:`~flask_admin.model.BaseModelView.export_max_rows`.
Grouping Views
==============
When adding a view, specify a value for the `category` parameter
to group related views together in the menu::
admin.add_view(UserView(User, db.session, category="Team"))
admin.add_view(ModelView(Role, db.session, category="Team"))
admin.add_view(ModelView(Permission, db.session, category="Team"))
This will create a top-level menu item named 'Team', and a drop-down containing
links to the three views.
To nest related views within these drop-downs, use the `add_sub_category` method::
admin.add_sub_category(name="Links", parent_name="Team")
And to add arbitrary hyperlinks to the menu:
admin.add_link(MenuLink(name='Home Page', url='/', category='Links'))
Adding Your Own Views
Adding Your Own Views
=====================
=====================
...
...
flask_admin/model/base.py
View file @
2b0c9e45
...
@@ -783,7 +783,7 @@ class BaseModelView(BaseView, ActionsMixin):
...
@@ -783,7 +783,7 @@ class BaseModelView(BaseView, ActionsMixin):
:param name:
:param name:
View name. If not provided, will use the model class name
View name. If not provided, will use the model class name
:param category:
:param category:
View category
Optional category name, for grouping views in the menu
:param endpoint:
:param endpoint:
Base endpoint. If not provided, will use the model name.
Base endpoint. If not provided, will use the model name.
:param url:
:param url:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment