01 Apr 2014 The Flask-Admin docs show how to override your base ModelView (wrap shared logic in a base class all your views inherit): flask-admin.readthedocs.io/en/latest/introduction
You would want to do this if you wanted to add something to all of your admin classes. Use cases:
If you wanted to require login by overriding is_accessible for all of your ModelViews. If you wanted to add an export method to all of your ModelViews. 01 Apr 2014 Edited: This was recently added to Flask-Admin as a feature.
You can add can_export = True to your ModelView to enable it.
More info here: https://flask-admin.readthedocs.io/en/stable/api/mod_model/#flask_admin.model.BaseModelView.can_export
01 Apr 2014 Updated 2026-09-23: updated both snippets for Python 3.
You need to add the following to your jinja2 template: {{ request.path ~ '?' ~ request.query_string.decode('utf-8') }}
You can also print only the Get Variables / URL Parameters / Argument String with the following: print(request.query_string.decode('utf-8'))
The example is available here: http://stackoverflow.com/a/11781872/1364191
28 Mar 2014 Common Filter Operators: http://manuelmax.tumblr.com/post/289720781/common-filter-operators-sqlalchemy
Common relationships: https://docs.sqlalchemy.org/en/20/orm/basic_relationships.html
If you’re using Flask-SQLalchemy, their documentation is an awesome quick summary of how to use SQLalchemy: https://flask-sqlalchemy.readthedocs.io/
27 Mar 2014 This link helped me use a temporary file for an excel export in flask (using pandas): https://coderwall.com/p/nwbuhq
27 Mar 2014 For a more complete example of using selectHandler, see this page: https://developers.google.com/chart/interactive/docs/basic_interactivity
My example below get the labels from the row and the columns. I used this to send the user to another link and drill-down.
// this is an example of a bar chart's selectHandler function
function selectHandler () {
var selection = chart . getSelection ();
var item = selection [ 0 ];
if ( item . row != null && item . column != null ) {
var rowLabel = parseInt ( data . getValue ( item . row , 0 ));
var columnLabel = data . getColumnLabel ( item . column );
}
}
google . visualization . events . addListener ( chart , ' select ' , selectHandler );
23 Mar 2014 Here’s an example of how to send ordered data with python’s Requests library, for when the order of your post request data matters:
import requests
from collections import OrderedDict
payload = OrderedDict ([( " username " , " admin " ), ( " pwd " , " password " )]) # the order matters!
r = requests . post ( ' http://198.51.100.1/example ' , data = payload )
print ( r . text )
18 Mar 2014 Update: I got this example added to the project: sqla-custom-filter example
This Github issue has an example of how to use custom filters in Flask-Admin: https://github.com/pallets-eco/flask-admin/issues/400
17 Mar 2014 You need to manually change the endpoint like MrJoes says in issue 480: https://github.com/pallets-eco/flask-admin/issues/480
Here’s an example:
admin . add_view ( MyModelView ( model . CsvTable , db . session , endpoint = " duplicate_view " ))
You can now visit your view by going to 0.0.0.0/admin/duplicate_view
04 Mar 2014 Updated 2026-08-29: flask.ext was removed in Flask 0.11, and the Bootstrap 2 icon class no longer renders under Flask-Admin’s Bootstrap 4 templates.
In your custom ModelView, you need to add the following lines:
from flask_admin.model.template import macro
column_formatters = dict ( your_column = macro ( ' render_your_column ' ))
list_template = ' list.html '
In your custom list.html template, you need to add the following jinja2 code:
{% macro render_your_column ( model , column ) %}
{% if model.your_column %} <i class= "fa fa-check glyphicon glyphicon-ok" ></i> {% endif %}
{% endmacro %}
If your row has a value in your_column, then it will show as a checkmark. You need to make a new macro for each column.