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
22bc4bd2
Commit
22bc4bd2
authored
Aug 01, 2015
by
Petrus J.v.Rensburg
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'docs'
parents
3cbca053
f4c59eb3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
2 deletions
+43
-2
advanced.rst
doc/advanced.rst
+34
-0
introduction.rst
doc/introduction.rst
+9
-2
No files found.
doc/advanced.rst
View file @
22bc4bd2
...
@@ -492,3 +492,37 @@ do with it, so it won't generate a form field. In this case, you would need to m
...
@@ -492,3 +492,37 @@ do with it, so it won't generate a form field. In this case, you would need to m
form_class.extra = TextField('Extra')
form_class.extra = TextField('Extra')
return form_class
return form_class
Customizing Batch Actions
-------------------------
****
If you want to add other batch actions to the list view, besides the default delete action,
then you can define a function that implements the desired logic and wrap it with the `@action` decorator.
The `action` decorator takes three parameters: `name`, `text` and `confirmation`.
While the wrapped function should accept only one parameter - `ids`::
from flask_admin.actions import action
class UserView(ModelView):
@action('approve', 'Approve', 'Are you sure you want to approve selected users?')
def action_approve(self, ids):
try:
query = User.query.filter(User.id.in_(ids))
count = 0
for user in query.all():
if user.approve():
count += 1
flash(ngettext('User was successfully approved.',
'%(count)s users were successfully approved.',
count,
count=count))
except Exception as ex:
if not self.handle_view_exception(ex):
raise
flash(gettext('Failed to approve users. %(error)s', error=str(ex)), 'error')
doc/introduction.rst
View file @
22bc4bd2
...
@@ -49,6 +49,7 @@ Straight out of the box, this gives you a set of fully featured *CRUD* views for
...
@@ -49,6 +49,7 @@ Straight out of the box, this gives you a set of fully featured *CRUD* views for
* A `list` view, with support for searching, sorting and filtering and deleting records.
* A `list` view, with support for searching, sorting and filtering and deleting records.
* A `create` view for adding new records.
* A `create` view for adding new records.
* An `edit` view for updating existing records.
* An `edit` view for updating existing records.
* An optional, read-only `detail` view.
There are many options available for customizing the display and functionality of these builtin views.
There are many options available for customizing the display and functionality of these builtin views.
For more details on that, see :ref:`customising-builtin-views`. For more details on the other
For more details on that, see :ref:`customising-builtin-views`. For more details on the other
...
@@ -221,6 +222,11 @@ To **disable some of the CRUD operations**, set any of these boolean parameters:
...
@@ -221,6 +222,11 @@ To **disable some of the CRUD operations**, set any of these boolean parameters:
can_edit = False
can_edit = False
can_delete = False
can_delete = False
If your model has too much data to display in the list view, you can **add a read-only
detail view** by setting::
can_view_details = True
**Removing columns** from the list view is easy, just pass a list of column names for
**Removing columns** from the list view is easy, just pass a list of column names for
the *column_excludes_list* parameter::
the *column_excludes_list* parameter::
...
@@ -236,9 +242,10 @@ For a faster editing experience, enable **inline editing** in the list view::
...
@@ -236,9 +242,10 @@ For a faster editing experience, enable **inline editing** in the list view::
column_editable_list = ['name', 'last_name']
column_editable_list = ['name', 'last_name']
Or, have the
edit form
display inside a **modal window** on the list page, in stead of
Or, have the
add & edit forms
display inside a **modal window** on the list page, in stead of
on the dedicated *
edit* page
::
on the dedicated *
create* & *edit* pages
::
create_modal = True
edit_modal = True
edit_modal = True
You can restrict the possible values for a text-field by specifying a list of **select choices**::
You can restrict the possible values for a text-field by specifying a list of **select choices**::
...
...
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