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
597ca07d
Commit
597ca07d
authored
Aug 27, 2015
by
Trevor Andreas
Committed by
Trevor Andreas
Sep 01, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement CSV export for BaseModelView.
parent
9db8c9e5
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
198 additions
and
10 deletions
+198
-10
introduction.rst
doc/introduction.rst
+6
-0
base.py
flask_admin/model/base.py
+175
-10
typefmt.py
flask_admin/model/typefmt.py
+5
-0
list.html
flask_admin/templates/bootstrap2/admin/model/list.html
+6
-0
list.html
flask_admin/templates/bootstrap3/admin/model/list.html
+6
-0
No files found.
doc/introduction.rst
View file @
597ca07d
...
@@ -298,6 +298,12 @@ To **manage related models inline**::
...
@@ -298,6 +298,12 @@ To **manage related models inline**::
These inline forms can be customised. Have a look at the API documentation for
These inline forms can be customised. Have a look at the API documentation for
:meth:`~flask_admin.contrib.sqla.ModelView.inline_models`.
:meth:`~flask_admin.contrib.sqla.ModelView.inline_models`.
To **enable csv export** of the model view::
can_export = True
This will add a button to the model view that exports records, truncating at :attr:`~flask_admin.model.BaseModelView.max_export_rows`.
Adding Your Own Views
Adding Your Own Views
=====================
=====================
...
...
flask_admin/model/base.py
100644 → 100755
View file @
597ca07d
This diff is collapsed.
Click to expand it.
flask_admin/model/typefmt.py
100644 → 100755
View file @
597ca07d
...
@@ -49,3 +49,8 @@ BASE_FORMATTERS = {
...
@@ -49,3 +49,8 @@ BASE_FORMATTERS = {
bool
:
bool_formatter
,
bool
:
bool_formatter
,
list
:
list_formatter
,
list
:
list_formatter
,
}
}
EXPORT_FORMATTERS
=
{
type
(
None
):
empty_formatter
,
list
:
list_formatter
,
}
flask_admin/templates/bootstrap2/admin/model/list.html
100644 → 100755
View file @
597ca07d
...
@@ -26,6 +26,12 @@
...
@@ -26,6 +26,12 @@
</li>
</li>
{% endif %}
{% endif %}
{% if admin_view.can_export %}
<li>
<a
href=
"{{ get_url('.export_csv', **request.args) }}"
title=
"{{ _gettext('Export') }}"
>
{{ _gettext('Export') }}
</a>
</li>
{% endif %}
{% if filters %}
{% if filters %}
<li
class=
"dropdown"
>
<li
class=
"dropdown"
>
{{ model_layout.filter_options() }}
{{ model_layout.filter_options() }}
...
...
flask_admin/templates/bootstrap3/admin/model/list.html
100644 → 100755
View file @
597ca07d
...
@@ -26,6 +26,12 @@
...
@@ -26,6 +26,12 @@
</li>
</li>
{% endif %}
{% endif %}
{% if admin_view.can_export %}
<li>
<a
href=
"{{ get_url('.export_csv', **request.args) }}"
title=
"{{ _gettext('Export') }}"
>
{{ _gettext('Export') }}
</a>
</li>
{% endif %}
{% if filters %}
{% if filters %}
<li
class=
"dropdown"
>
<li
class=
"dropdown"
>
{{ model_layout.filter_options() }}
{{ model_layout.filter_options() }}
...
...
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