Commit 597ca07d authored by Trevor Andreas's avatar Trevor Andreas Committed by Trevor Andreas

Implement CSV export for BaseModelView.

parent 9db8c9e5
......@@ -298,6 +298,12 @@ To **manage related models inline**::
These inline forms can be customised. Have a look at the API documentation for
: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
=====================
......
This diff is collapsed.
......@@ -49,3 +49,8 @@ BASE_FORMATTERS = {
bool: bool_formatter,
list: list_formatter,
}
EXPORT_FORMATTERS = {
type(None): empty_formatter,
list: list_formatter,
}
......@@ -26,6 +26,12 @@
</li>
{% 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 %}
<li class="dropdown">
{{ model_layout.filter_options() }}
......
......@@ -26,6 +26,12 @@
</li>
{% 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 %}
<li class="dropdown">
{{ model_layout.filter_options() }}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment