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
a5d1bf79
Commit
a5d1bf79
authored
Feb 07, 2017
by
Paul Brown
Committed by
GitHub
Feb 07, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1417 from jammie987/peewee_json_field
Added JSON and JSONB and support for peewee postgresql backend
parents
6e5757d1
43971217
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
form.py
flask_admin/contrib/peewee/form.py
+12
-0
No files found.
flask_admin/contrib/peewee/form.py
View file @
a5d1bf79
...
...
@@ -12,6 +12,11 @@ from flask_admin.model.fields import InlineModelFormField, InlineFieldList, Ajax
from
.tools
import
get_primary_key
,
get_meta_fields
from
.ajax
import
create_ajax_loader
try
:
from
playhouse.postgres_ext
import
JSONField
,
BinaryJSONField
pg_ext
=
True
except
:
pg_ext
=
False
class
InlineModelFormList
(
InlineFieldList
):
...
...
@@ -106,6 +111,10 @@ class CustomModelConverter(ModelConverter):
self
.
converters
[
DateField
]
=
self
.
handle_date
self
.
converters
[
TimeField
]
=
self
.
handle_time
if
pg_ext
:
self
.
converters
[
JSONField
]
=
self
.
handle_json
self
.
converters
[
BinaryJSONField
]
=
self
.
handle_json
self
.
overrides
=
getattr
(
self
.
view
,
'form_overrides'
,
None
)
or
{}
def
handle_foreign_key
(
self
,
model
,
field
,
**
kwargs
):
...
...
@@ -134,6 +143,9 @@ class CustomModelConverter(ModelConverter):
def
handle_time
(
self
,
model
,
field
,
**
kwargs
):
return
field
.
name
,
form
.
TimeField
(
**
kwargs
)
def
handle_json
(
self
,
model
,
field
,
**
kwargs
):
return
field
.
name
,
form
.
JSONField
(
**
kwargs
)
def
get_form
(
model
,
converter
,
base_class
=
form
.
BaseForm
,
...
...
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