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
7cd9efdf
Commit
7cd9efdf
authored
Sep 11, 2012
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If sqla form field is overridden, it won't receive sqla-related field parameters. Fixes #57
parent
12411641
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
form.py
flask_admin/contrib/sqlamodel/form.py
+7
-5
No files found.
flask_admin/contrib/sqlamodel/form.py
View file @
7cd9efdf
...
@@ -50,11 +50,7 @@ class AdminModelConverter(ModelConverterBase):
...
@@ -50,11 +50,7 @@ class AdminModelConverter(ModelConverterBase):
remote_model
=
prop
.
mapper
.
class_
remote_model
=
prop
.
mapper
.
class_
local_column
=
prop
.
local_remote_pairs
[
0
][
0
]
local_column
=
prop
.
local_remote_pairs
[
0
][
0
]
kwargs
.
update
({
kwargs
[
'label'
]
=
self
.
_get_label
(
prop
.
key
,
kwargs
)
'allow_blank'
:
local_column
.
nullable
,
'label'
:
self
.
_get_label
(
prop
.
key
,
kwargs
),
'query_factory'
:
lambda
:
self
.
session
.
query
(
remote_model
)
})
if
local_column
.
nullable
:
if
local_column
.
nullable
:
kwargs
[
'validators'
]
.
append
(
validators
.
Optional
())
kwargs
[
'validators'
]
.
append
(
validators
.
Optional
())
...
@@ -66,6 +62,12 @@ class AdminModelConverter(ModelConverterBase):
...
@@ -66,6 +62,12 @@ class AdminModelConverter(ModelConverterBase):
if
override
:
if
override
:
return
override
(
**
kwargs
)
return
override
(
**
kwargs
)
# Contribute model-related parameters
kwargs
.
update
({
'allow_blank'
:
local_column
.
nullable
,
'query_factory'
:
lambda
:
self
.
session
.
query
(
remote_model
)
})
if
prop
.
direction
.
name
==
'MANYTOONE'
:
if
prop
.
direction
.
name
==
'MANYTOONE'
:
return
QuerySelectField
(
widget
=
form
.
ChosenSelectWidget
(),
return
QuerySelectField
(
widget
=
form
.
ChosenSelectWidget
(),
**
kwargs
)
**
kwargs
)
...
...
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