Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
84170e85
Commit
84170e85
authored
Sep 26, 2012
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #52. Added list_display_pk properties to model views
parent
960cbdd5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
4 deletions
+18
-4
mod_model.rst
doc/api/mod_model.rst
+1
-0
simple.py
examples/sqla/simple.py
+2
-0
view.py
flask_admin/contrib/peeweemodel/view.py
+2
-2
view.py
flask_admin/contrib/sqlamodel/view.py
+8
-2
base.py
flask_admin/model/base.py
+5
-0
No files found.
doc/api/mod_model.rst
View file @
84170e85
...
...
@@ -23,6 +23,7 @@
.. autoattribute:: excluded_list_columns
.. autoattribute:: rename_columns
.. autoattribute:: list_formatters
.. autoattribute:: list_display_pk
.. autoattribute:: sortable_columns
...
...
examples/sqla/simple.py
View file @
84170e85
...
...
@@ -81,6 +81,8 @@ def index():
class
UserAdmin
(
sqlamodel
.
ModelView
):
inline_models
=
(
UserInfo
,)
list_display_pk
=
True
# Customized Post model admin
class
PostAdmin
(
sqlamodel
.
ModelView
):
...
...
flask_admin/contrib/peeweemodel/view.py
View file @
84170e85
...
...
@@ -123,7 +123,7 @@ class ModelView(BaseModelView):
if
field_class
==
ForeignKeyField
:
columns
.
append
(
n
)
elif
field_class
!=
PrimaryKeyField
:
elif
self
.
list_display_pk
or
field_class
!=
PrimaryKeyField
:
columns
.
append
(
n
)
return
columns
...
...
@@ -132,7 +132,7 @@ class ModelView(BaseModelView):
columns
=
dict
()
for
n
,
f
in
self
.
_get_model_fields
():
if
type
(
f
)
!=
PrimaryKeyField
:
if
self
.
list_display_pk
or
type
(
f
)
!=
PrimaryKeyField
:
columns
[
n
]
=
f
return
columns
...
...
flask_admin/contrib/sqlamodel/view.py
View file @
84170e85
...
...
@@ -245,7 +245,10 @@ class ModelView(BaseModelView):
# TODO: Check for multiple columns
column
=
p
.
columns
[
0
]
if
column
.
foreign_keys
or
column
.
primary_key
:
if
column
.
foreign_keys
:
continue
if
not
self
.
list_display_pk
and
column
.
primary_key
:
continue
columns
.
append
(
p
.
key
)
...
...
@@ -270,7 +273,10 @@ class ModelView(BaseModelView):
column
=
p
.
columns
[
0
]
# Can't sort by on primary and foreign keys by default
if
column
.
foreign_keys
or
column
.
primary_key
:
if
column
.
foreign_keys
:
continue
if
not
self
.
list_display_pk
and
column
.
primary_key
:
continue
columns
[
p
.
key
]
=
column
...
...
flask_admin/model/base.py
View file @
84170e85
...
...
@@ -147,6 +147,11 @@ class BaseModelView(BaseView, ActionsMixin):
column_filters = ('user', 'email')
"""
list_display_pk
=
False
"""
Controls if primary key should be displayed in list view.
"""
form
=
None
"""
Form class. Override if you want to use custom form for your model.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment