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
81646c0c
Commit
81646c0c
authored
Oct 13, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #328. Check if local column is foreign key, if not - use remote column
parent
5b9e3060
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
form.py
flask_admin/contrib/sqla/form.py
+8
-3
No files found.
flask_admin/contrib/sqla/form.py
View file @
81646c0c
...
...
@@ -98,19 +98,24 @@ class AdminModelConverter(ModelConverterBase):
def
_convert_relation
(
self
,
prop
,
kwargs
):
remote_model
=
prop
.
mapper
.
class_
local_column
=
prop
.
local_remote_pairs
[
0
][
0
]
column
=
prop
.
local_remote_pairs
[
0
][
0
]
# If this relation points to local column that's not foreign key, assume
# that it is backref and use remote column data
if
not
column
.
foreign_keys
:
column
=
prop
.
local_remote_pairs
[
0
][
1
]
kwargs
[
'label'
]
=
self
.
_get_label
(
prop
.
key
,
kwargs
)
kwargs
[
'description'
]
=
self
.
_get_description
(
prop
.
key
,
kwargs
)
if
local_
column
.
nullable
:
if
column
.
nullable
:
kwargs
[
'validators'
]
.
append
(
validators
.
Optional
())
elif
prop
.
direction
.
name
!=
'MANYTOMANY'
:
kwargs
[
'validators'
]
.
append
(
validators
.
InputRequired
())
# Contribute model-related parameters
if
'allow_blank'
not
in
kwargs
:
kwargs
[
'allow_blank'
]
=
local_
column
.
nullable
kwargs
[
'allow_blank'
]
=
column
.
nullable
# Override field type if necessary
override
=
self
.
_get_field_override
(
prop
.
key
)
...
...
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