Permalink
Browse files

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

…any-to-one relation data in list view
  • Loading branch information...
1 parent 019dca3 commit 81b54bcd342a9bfb6ea5fad283a3d43cd2eca1c2 @mrjoes mrjoes committed Sep 26, 2012
Showing with 9 additions and 4 deletions.
  1. +2 −2 examples/sqla/simple.py
  2. +1 −1 flask_admin/base.py
  3. +6 −1 flask_admin/contrib/sqlamodel/view.py
View
@@ -81,15 +81,15 @@ def index():
class UserAdmin(sqlamodel.ModelView):
inline_models = (UserInfo,)
- list_display_pk = True
-
# Customized Post model admin
class PostAdmin(sqlamodel.ModelView):
# Visible columns in the list view
#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')
View
@@ -229,7 +229,7 @@ class MyHomeView(AdminIndexView):
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 PostAdmin(ModelAdmin):
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 @@ def scaffold_list_columns(self):
# 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

0 comments on commit 81b54bc

Please sign in to comment.