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
ddf6843b
Commit
ddf6843b
authored
Nov 17, 2015
by
Paul Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sqla ajax loader - allow primary key name != attribute names
parent
258ae974
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
ajax.py
flask_admin/contrib/sqla/ajax.py
+4
-3
No files found.
flask_admin/contrib/sqla/ajax.py
View file @
ddf6843b
...
@@ -3,6 +3,8 @@ from sqlalchemy import or_
...
@@ -3,6 +3,8 @@ from sqlalchemy import or_
from
flask_admin._compat
import
as_unicode
,
string_types
from
flask_admin._compat
import
as_unicode
,
string_types
from
flask_admin.model.ajax
import
AjaxModelLoader
,
DEFAULT_PAGE_SIZE
from
flask_admin.model.ajax
import
AjaxModelLoader
,
DEFAULT_PAGE_SIZE
from
.tools
import
get_primary_key
,
has_multiple_pks
class
QueryAjaxModelLoader
(
AjaxModelLoader
):
class
QueryAjaxModelLoader
(
AjaxModelLoader
):
def
__init__
(
self
,
name
,
session
,
model
,
**
options
):
def
__init__
(
self
,
name
,
session
,
model
,
**
options
):
...
@@ -24,11 +26,10 @@ class QueryAjaxModelLoader(AjaxModelLoader):
...
@@ -24,11 +26,10 @@ class QueryAjaxModelLoader(AjaxModelLoader):
self
.
_cached_fields
=
self
.
_process_fields
()
self
.
_cached_fields
=
self
.
_process_fields
()
primary_keys
=
model
.
_sa_class_manager
.
mapper
.
primary_key
if
has_multiple_pks
(
model
):
if
len
(
primary_keys
)
>
1
:
raise
NotImplementedError
(
'Flask-Admin does not support multi-pk AJAX model loading.'
)
raise
NotImplementedError
(
'Flask-Admin does not support multi-pk AJAX model loading.'
)
self
.
pk
=
primary_keys
[
0
]
.
name
self
.
pk
=
get_primary_key
(
model
)
def
_process_fields
(
self
):
def
_process_fields
(
self
):
remote_fields
=
[]
remote_fields
=
[]
...
...
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