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
de025273
Commit
de025273
authored
Mar 23, 2012
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Quickstart docs update.
parent
aa499615
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
89 additions
and
3 deletions
+89
-3
quickstart_1.png
doc/images/quickstart/quickstart_1.png
+0
-0
quickstart_2.png
doc/images/quickstart/quickstart_2.png
+0
-0
quickstart_3.png
doc/images/quickstart/quickstart_3.png
+0
-0
quickstart_4.png
doc/images/quickstart/quickstart_4.png
+0
-0
quickstart_5.png
doc/images/quickstart/quickstart_5.png
+0
-0
quickstart.rst
doc/quickstart.rst
+47
-3
first.py
examples/quickstart/first.py
+8
-0
second.py
examples/quickstart/second.py
+15
-0
index.html
examples/quickstart/templates/index.html
+4
-0
third.py
examples/quickstart/third.py
+15
-0
No files found.
doc/images/quickstart/quickstart_1.png
0 → 100644
View file @
de025273
3 KB
doc/images/quickstart/quickstart_2.png
0 → 100644
View file @
de025273
7.12 KB
doc/images/quickstart/quickstart_3.png
0 → 100644
View file @
de025273
10.7 KB
doc/images/quickstart/quickstart_4.png
0 → 100644
View file @
de025273
17.3 KB
doc/images/quickstart/quickstart_5.png
0 → 100644
View file @
de025273
22.9 KB
doc/quickstart.rst
View file @
de025273
...
@@ -48,7 +48,10 @@ To start using Flask-AdminEx, you have to create `Admin` class instance and asso
...
@@ -48,7 +48,10 @@ To start using Flask-AdminEx, you have to create `Admin` class instance and asso
app.run()
app.run()
If you start this application and navigate to `http://localhost:5000/admin/ <http://localhost:5000/admin/>`_,
If you start this application and navigate to `http://localhost:5000/admin/ <http://localhost:5000/admin/>`_,
you should see empty "Home" page with a navigation bar on top.
you should see empty "Home" page with a navigation bar on top
.. image:: images/quickstart/quickstart_1.png
:target: _images/quickstart_1.png
You can change application name by passing `name` parameter to the `Admin` class constructor::
You can change application name by passing `name` parameter to the `Admin` class constructor::
...
@@ -68,7 +71,7 @@ Adding view
...
@@ -68,7 +71,7 @@ Adding view
Now, lets add a view. To do this, you need to derive from `BaseView` class::
Now, lets add a view. To do this, you need to derive from `BaseView` class::
from flask import Flask
from flask import Flask
from flask.ext.adminex import Admin, BaseView
from flask.ext.adminex import Admin, BaseView
, expose
class MyView(BaseView):
class MyView(BaseView):
@expose('/')
@expose('/')
...
@@ -102,6 +105,35 @@ All administrative pages should derive from the 'admin/master.html' to maintain
...
@@ -102,6 +105,35 @@ All administrative pages should derive from the 'admin/master.html' to maintain
If you will refresh 'Hello' administrative page again you should see greeting in the content section.
If you will refresh 'Hello' administrative page again you should see greeting in the content section.
.. image:: images/quickstart/quickstart_2.png
:width: 640
:target: _images/quickstart_2.png
You're not limited to top level menu. It is possible to pass category name and it will be used as a
top menu item. For example::
from flask import Flask
from flask.ext.adminex import Admin, BaseView, expose
class MyView(BaseView):
@expose('/')
def index(self):
return self.render('index.html')
app = Flask(__name__)
admin = Admin(app)
admin.add_view(MyView(name='Hello 1', endpoint='test1', category='Test'))
admin.add_view(MyView(name='Hello 2', endpoint='test2', category='Test'))
admin.add_view(MyView(name='Hello 3', endpoint='test3', category='Test'))
app.run()
Will look like this:
.. image:: images/quickstart/quickstart_3.png
:width: 640
:target: _images/quickstart_3.png
Authentication
Authentication
--------------
--------------
...
@@ -130,7 +162,7 @@ prefix to get URL to a local view::
...
@@ -130,7 +162,7 @@ prefix to get URL to a local view::
class MyView(BaseView):
class MyView(BaseView):
@expose('/')
@expose('/')
def index(self)
def index(self)
# Get URL for the
`test`
view method
# Get URL for the
test
view method
url = url_for('.test')
url = url_for('.test')
return self.render('index.html', url=url)
return self.render('index.html', url=url)
...
@@ -174,6 +206,12 @@ Flask-AdminEx comes with built-in SQLAlchemy model administrative interface. It
...
@@ -174,6 +206,12 @@ Flask-AdminEx comes with built-in SQLAlchemy model administrative interface. It
This will create administrative interface for `User` model with default settings.
This will create administrative interface for `User` model with default settings.
Here is how default list view looks like:
.. image:: images/quickstart/quickstart_4.png
:width: 640
:target: _images/quickstart_4.png
If you want to customize model views, you have two options:
If you want to customize model views, you have two options:
1. Change behavior by overriding public properties that control how view works
1. Change behavior by overriding public properties that control how view works
...
@@ -218,6 +256,12 @@ Here is simple example::
...
@@ -218,6 +256,12 @@ Here is simple example::
path = op.join(op.dirname(__file__), 'static')
path = op.join(op.dirname(__file__), 'static')
admin.add_view(path, '/static/', name='Static Files')
admin.add_view(path, '/static/', name='Static Files')
Sample screenshot:
.. image:: images/quickstart/quickstart_5.png
:width: 640
:target: _images/quickstart_5.png
You can disable uploads, disable file or directory deletion, restrict file uploads to certain types and so on.
You can disable uploads, disable file or directory deletion, restrict file uploads to certain types and so on.
Check :mod:`flask.ext.adminex.ext.fileadmin` documentation on how to do it.
Check :mod:`flask.ext.adminex.ext.fileadmin` documentation on how to do it.
...
...
examples/quickstart/first.py
0 → 100644
View file @
de025273
from
flask
import
Flask
from
flask.ext.adminex
import
Admin
app
=
Flask
(
__name__
)
admin
=
Admin
(
app
)
app
.
run
()
examples/quickstart/second.py
0 → 100644
View file @
de025273
from
flask
import
Flask
from
flask.ext.adminex
import
Admin
,
BaseView
,
expose
class
MyView
(
BaseView
):
@
expose
(
'/'
)
def
index
(
self
):
return
self
.
render
(
'index.html'
)
app
=
Flask
(
__name__
)
admin
=
Admin
(
app
)
admin
.
add_view
(
MyView
(
name
=
'Hello'
))
app
.
run
()
examples/quickstart/templates/index.html
0 → 100644
View file @
de025273
{% extends 'admin/master.html' %}
{% block body %}
Hello World from MyView!
{% endblock %}
examples/quickstart/third.py
0 → 100644
View file @
de025273
from
flask
import
Flask
from
flask.ext.adminex
import
Admin
,
BaseView
,
expose
class
MyView
(
BaseView
):
@
expose
(
'/'
)
def
index
(
self
):
return
self
.
render
(
'index.html'
)
app
=
Flask
(
__name__
)
admin
=
Admin
(
app
)
admin
.
add_view
(
MyView
(
name
=
'Hello 1'
,
endpoint
=
'test1'
,
category
=
'Test'
))
admin
.
add_view
(
MyView
(
name
=
'Hello 2'
,
endpoint
=
'test2'
,
category
=
'Test'
))
admin
.
add_view
(
MyView
(
name
=
'Hello 3'
,
endpoint
=
'test3'
,
category
=
'Test'
))
app
.
run
()
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