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
5eec11e8
Commit
5eec11e8
authored
Jul 16, 2015
by
Paul Brown
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #947 from plaes/date-formatter-example
Add custom date example for column_type_formatter
parents
06156d86
08883096
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
base.py
flask_admin/model/base.py
+8
-2
No files found.
flask_admin/model/base.py
View file @
5eec11e8
...
...
@@ -166,6 +166,7 @@ class BaseModelView(BaseView, ActionsMixin):
Dictionary of value type formatters to be used in the list view.
By default, two types are formatted:
1. ``None`` will be displayed as an empty string
2. ``bool`` will be displayed as a checkmark if it is ``True``
...
...
@@ -176,13 +177,18 @@ class BaseModelView(BaseView, ActionsMixin):
column_type_formatters = dict()
If you want to display `NULL` instead of an empty string, you can do
something like this::
something like this
. Also comes with bonus `date` formatter
::
from datetime import date
from flask_admin.model import typefmt
def date_format(view, value):
return value.strftime('
%
d.
%
m.
%
Y')
MY_DEFAULT_FORMATTERS = dict(typefmt.BASE_FORMATTERS)
MY_DEFAULT_FORMATTERS.update({
type(None): typefmt.null_formatter
type(None): typefmt.null_formatter,
date: date_format
})
class MyModelView(BaseModelView):
...
...
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