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
0452e961
Commit
0452e961
authored
Mar 22, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get_query() for ORM backends
parent
0c436e72
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
8 deletions
+20
-8
changelog.rst
doc/changelog.rst
+5
-0
quickstart.rst
doc/quickstart.rst
+7
-3
view.py
flask_admin/contrib/mongoengine/view.py
+4
-4
view.py
flask_admin/contrib/peeweemodel/view.py
+4
-1
No files found.
doc/changelog.rst
View file @
0452e961
Changelog
=========
1.0.5
-----
1.0.4
-----
...
...
doc/quickstart.rst
View file @
0452e961
...
...
@@ -4,6 +4,8 @@ Quick Start
This page gives quick introduction to Flask-Admin library. It is assumed that reader has some prior
knowledge of the `Flask <http://flask.pocoo.org/>`_ framework.
If you're Django user, you might also find :doc:`django_migration` guide helpful.
Introduction
------------
...
...
@@ -24,14 +26,16 @@ Here is absolutely valid administrative piece::
def test(self):
return self.render('admin/test.html')
If user will hit `index` view, `admin/myindex.html` template will be rendered. Same for `test` view.
So, how does it help structuring administrative interface? With such building blocks, you're
implementing reusable functional pieces that are highly customizable.
For example, Flask-Admin provides ready-to-use SQLAlchemy model interface. It is implemented as a
class which accepts two parameters: model and a database session. While it exposes some
class which accepts two parameters: model
class
and a database session. While it exposes some
class-level variables which change behavior of the interface (somewhat similar to django.contrib.admin),
nothing prohibits you from
overriding form creation logic, database access methods or extending existing
functionality
.
nothing prohibits you from
inheriting from it and override form creation logic, database access methods
or extend existing functionality by adding more views
.
Initialization
--------------
...
...
flask_admin/contrib/mongoengine/view.py
View file @
0452e961
...
...
@@ -240,7 +240,7 @@ class ModelView(BaseModelView):
return
form_class
def
get_query
set
(
self
):
def
get_query
(
self
):
"""
Returns the QuerySet for this view. By default, it returns all the
objects for the current model.
...
...
@@ -265,7 +265,7 @@ class ModelView(BaseModelView):
:param execute:
Run query immediately or not
"""
query
=
self
.
get_query
set
()
query
=
self
.
get_query
()
# Filters
if
self
.
_filters
:
...
...
@@ -319,7 +319,7 @@ class ModelView(BaseModelView):
:param id:
Model ID
"""
return
self
.
get_query
set
()
.
filter
(
pk
=
id
)
.
first
()
return
self
.
get_query
()
.
filter
(
pk
=
id
)
.
first
()
def
create_model
(
self
,
form
):
"""
...
...
@@ -393,7 +393,7 @@ class ModelView(BaseModelView):
count
=
0
all_ids
=
[
ObjectId
(
pk
)
for
pk
in
ids
]
for
obj
in
self
.
get_query
set
()
.
in_bulk
(
all_ids
)
.
values
():
for
obj
in
self
.
get_query
()
.
in_bulk
(
all_ids
)
.
values
():
obj
.
delete
()
count
+=
1
...
...
flask_admin/contrib/peeweemodel/view.py
View file @
0452e961
...
...
@@ -252,9 +252,12 @@ class ModelView(BaseModelView):
return
query
def
get_query
(
self
):
return
self
.
model
.
select
()
def
get_list
(
self
,
page
,
sort_column
,
sort_desc
,
search
,
filters
,
execute
=
True
):
query
=
self
.
model
.
select
()
query
=
self
.
get_query
()
joins
=
set
()
...
...
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