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
07727643
Unverified
Commit
07727643
authored
Nov 07, 2018
by
Petrus Janse van Rensburg
Committed by
GitHub
Nov 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1749 from lapseofreason/master
Improve documentation of contrib.sqla.ModelView.get_query.
parents
43567732
102f2c0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
view.py
flask_admin/contrib/sqla/view.py
+13
-0
No files found.
flask_admin/contrib/sqla/view.py
View file @
07727643
...
@@ -833,6 +833,17 @@ class ModelView(BaseModelView):
...
@@ -833,6 +833,17 @@ class ModelView(BaseModelView):
class MyView(ModelView):
class MyView(ModelView):
def get_query(self):
def get_query(self):
return super(MyView, self).get_query().filter(User.username == current_user.username)
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()
"""
"""
return
self
.
session
.
query
(
self
.
model
)
return
self
.
session
.
query
(
self
.
model
)
...
@@ -1073,6 +1084,8 @@ class ModelView(BaseModelView):
...
@@ -1073,6 +1084,8 @@ class ModelView(BaseModelView):
"""
"""
Return a single model by its id.
Return a single model by its id.
Also see `get_query` for how to filter the list view.
:param id:
:param id:
Model id
Model 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