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
8bc5e9cd
Commit
8bc5e9cd
authored
Nov 01, 2016
by
Paul Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sqla - prevent AjaxSelectField autoflush while populating model
parent
d84945cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
app.py
examples/sqla/app.py
+1
-2
ajax.py
flask_admin/contrib/sqla/ajax.py
+3
-1
No files found.
examples/sqla/app.py
View file @
8bc5e9cd
...
...
@@ -20,8 +20,7 @@ app.config['SECRET_KEY'] = '123456790'
app
.
config
[
'DATABASE_FILE'
]
=
'sample_db.sqlite'
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///'
+
app
.
config
[
'DATABASE_FILE'
]
app
.
config
[
'SQLALCHEMY_ECHO'
]
=
True
session_options
=
dict
(
autoflush
=
False
)
db
=
SQLAlchemy
(
app
,
session_options
=
session_options
)
db
=
SQLAlchemy
(
app
)
# Create models
...
...
flask_admin/contrib/sqla/ajax.py
View file @
8bc5e9cd
...
...
@@ -55,7 +55,9 @@ class QueryAjaxModelLoader(AjaxModelLoader):
return
(
getattr
(
model
,
self
.
pk
),
as_unicode
(
model
))
def
get_one
(
self
,
pk
):
return
self
.
session
.
query
(
self
.
model
)
.
get
(
pk
)
# prevent autoflush from occuring during populate_obj
with
self
.
session
.
no_autoflush
:
return
self
.
session
.
query
(
self
.
model
)
.
get
(
pk
)
def
get_list
(
self
,
term
,
offset
=
0
,
limit
=
DEFAULT_PAGE_SIZE
):
query
=
self
.
session
.
query
(
self
.
model
)
...
...
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