Commit 81b54bcd authored by Serge S. Koval's avatar Serge S. Koval

Fixed #59. Added list_display_all_relations to sqla backend to show...

Fixed #59. Added list_display_all_relations to sqla backend to show many-to-one relation data in list view
parent 019dca33
......@@ -81,8 +81,6 @@ def index():
class UserAdmin(sqlamodel.ModelView):
inline_models = (UserInfo,)
list_display_pk = True
# Customized Post model admin
class PostAdmin(sqlamodel.ModelView):
......@@ -90,6 +88,8 @@ class PostAdmin(sqlamodel.ModelView):
#list_columns = ('title', 'user')
excluded_list_columns = ['text']
list_display_all_relations = True
# List of columns that can be sorted. For 'user' column, use User.username as
# a column.
sortable_columns = ('title', ('user', User.username), 'date')
......
......@@ -229,7 +229,7 @@ class AdminIndexView(BaseView):
def index(self):
return render_template('adminhome.html')
admin = Admin(index_view=MyHomeView)
admin = Admin(index_view=MyHomeView())
Default values for the index page are following:
......
......@@ -56,6 +56,11 @@ class ModelView(BaseModelView):
Please refer to the `subqueryload` on list of possible values.
"""
list_display_all_relations = False
"""
Controls if list view should display all relations, not only many-to-one.
"""
searchable_columns = None
"""
Collection of the searchable columns. Only text-based columns
......@@ -239,7 +244,7 @@ class ModelView(BaseModelView):
# Verify type
if hasattr(p, 'direction'):
if p.direction.name == 'MANYTOONE':
if self.list_display_all_relations or p.direction.name == 'MANYTOONE':
columns.append(p.key)
elif hasattr(p, 'columns'):
# TODO: Check for multiple columns
......
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