more tweaks sqla example app

parent abff067d
...@@ -338,6 +338,7 @@ class PostAdmin(sqla.ModelView): ...@@ -338,6 +338,7 @@ class PostAdmin(sqla.ModelView):
class TreeView(sqla.ModelView): class TreeView(sqla.ModelView):
list_template = 'tree_list.html'
column_auto_select_related = True column_auto_select_related = True
column_list = [ column_list = [
'id', 'id',
...@@ -347,6 +348,9 @@ class TreeView(sqla.ModelView): ...@@ -347,6 +348,9 @@ class TreeView(sqla.ModelView):
form_excluded_columns = ['children', ] form_excluded_columns = ['children', ]
column_filters = ['id', 'name', 'parent',] column_filters = ['id', 'name', 'parent',]
# override the 'render' method to pass your own parameters to the template
def render(self, template, **kwargs):
return super(TreeView, self).render(template, foo="bar", **kwargs)
# Create admin # Create admin
admin = admin.Admin(app, name='Example: SQLAlchemy', template_mode='bootstrap3') admin = admin.Admin(app, name='Example: SQLAlchemy', template_mode='bootstrap3')
......
Flask Flask
-e /Users/petrus/code/flask-admin Flask-Admin
Flask-BabelEx Flask-BabelEx
Flask-SQLAlchemy Flask-SQLAlchemy
tablib tablib
......
{% extends 'admin/model/list.html' %}
{% block body %}
<p>
This view demonstrated a tree structure, where there's a recursive relationship
between records on the same table.
<p>
<p>
It also demonstrates how to extend the builtin <em>list.html</em> template, and
pass your own parameters to the template. E.g. the parameter: <em>foo</em>, which
has the value <b>{{ foo }}</b>, passed in dynamically from the <em>{{ h.get_current_view().name }}</em> view.
</p>
{{ super() }}
{% endblock %}
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