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
005a4636
Commit
005a4636
authored
Nov 07, 2018
by
PJ Janse van Rensburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak docstring for get_query and get_one
parent
07727643
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
view.py
flask_admin/contrib/sqla/view.py
+8
-11
No files found.
flask_admin/contrib/sqla/view.py
View file @
005a4636
...
...
@@ -824,8 +824,6 @@ class ModelView(BaseModelView):
"""
Return a query for the model type.
If you override this method, don't forget to override `get_count_query` as well.
This method can be used to set a "persistent filter" on an index_view.
Example::
...
...
@@ -834,16 +832,9 @@ class ModelView(BaseModelView):
def get_query(self):
return super(MyView, self).get_query().filter(User.username == current_user.username)
Individual elements that are filtered in the list view are still
accessible through the edit view by simply changing the URL, even
when they are filtered by `get_query`. To prohibit this, also
override `get_one`.
Example::
def get_one(self, id):
query = self.get_query()
return query.filter(self.model.id == id).first()
If you override this method, don't forget to also override `get_count_query`, for displaying the correct
item count in the list view, and `get_one`, which is used when retrieving records for the edit view.
"""
return
self
.
session
.
query
(
self
.
model
)
...
...
@@ -1084,6 +1075,12 @@ class ModelView(BaseModelView):
"""
Return a single model by its id.
Example::
def get_one(self, id):
query = self.get_query()
return query.filter(self.model.id == id).one()
Also see `get_query` for how to filter the list view.
:param id:
...
...
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