Commit 1608f817 authored by Petrus J.v.Rensburg's avatar Petrus J.v.Rensburg

Tweaks all round.

parent ba8b0bc3
Advanced Advanced
=========== ===========
Initialisation:
---------------
As an alternative to passing a Flask application object to the Admin constructor, you can also call the
:meth:`~flask_admin.base.Admin.init_app` function, after the Admin instance has been initialized::
admin = Admin(name='My App', template_mode='bootstrap3')
# Add views here
admin.init_app(app)
Enabling localization Enabling localization
----------- -----------
Flask-Admin makes it possible for you to serve your application in more than one language. To do this, it makes use of Flask-Admin makes it possible for you to serve your application in more than one language. To do this, it makes use of
......
...@@ -11,10 +11,10 @@ with your database models, and it doesn't require you to write any new view logi ...@@ -11,10 +11,10 @@ with your database models, and it doesn't require you to write any new view logi
template code. So it's great for when you're deploying something that's still template code. So it's great for when you're deploying something that's still
under development, before you want the whole world to see it. under development, before you want the whole world to see it.
Have a look at `Flask-BasicAuth <http://flask-basicauth.readthedocs.org/>`_ to see how Have a look at `Flask-BasicAuth <http://flask-basicauth.readthedocs.org/>`_ to see just how
easy it is to put your whole application behind HTTP Basic Auth. easy it is to put your whole application behind HTTP Basic Auth.
Unfortunately, there's no easy way of applying HTTP Basic Auth just to your admin Unfortunately, there is no easy way of applying HTTP Basic Auth just to your admin
interface. interface.
Rolling your own Rolling your own
...@@ -22,7 +22,7 @@ Rolling your own ...@@ -22,7 +22,7 @@ Rolling your own
For a finer-grained solution, Flask-Admin lets you define access control rules For a finer-grained solution, Flask-Admin lets you define access control rules
on each of your admin view classes by simply overriding the `is_accessible` method. on each of your admin view classes by simply overriding the `is_accessible` method.
How you implement the logic is up to you, but if you were to use a low-level library like How you implement the logic is up to you, but if you were to use a low-level library like
`Flask-Login <https://flask-login.readthedocs.org/>`_, then restricting access to a set of views `Flask-Login <https://flask-login.readthedocs.org/>`_, then restricting access
could be as simple as:: could be as simple as::
class MyModelView(sqla.ModelView): class MyModelView(sqla.ModelView):
...@@ -34,8 +34,7 @@ However, you would still need to implement all of the relevant login / ...@@ -34,8 +34,7 @@ However, you would still need to implement all of the relevant login /
registration views yourself. registration views yourself.
If you like this approach, then have a look at the example at If you like this approach, then have a look at the example at
https://github.com/flask-admin/Flask-Admin/tree/master/examples/auth-flask-login https://github.com/flask-admin/Flask-Admin/tree/master/examples/auth-flask-login.
to get started.
Using Flask-Security Using Flask-Security
-------------------------------- --------------------------------
......
...@@ -2,7 +2,7 @@ Getting Started ...@@ -2,7 +2,7 @@ Getting Started
=========== ===========
Flask-Admin lets you build complicated interfaces by grouping individual views Flask-Admin lets you build complicated interfaces by grouping individual views
together in classes. So each view that you see from the frontend, represents a together in classes: Each view that you see on the frontend, represents a
method on a class that has explicitly been added to the interface. method on a class that has explicitly been added to the interface.
These view classes are especially helpful when they are tied to particular These view classes are especially helpful when they are tied to particular
...@@ -29,19 +29,10 @@ The first step, is to initialise an empty admin interface on your Flask app:: ...@@ -29,19 +29,10 @@ The first step, is to initialise an empty admin interface on your Flask app::
Here, both the *name* and *template_mode* parameters are optional. If you start this application and navigate to `http://localhost:5000/admin/ <http://localhost:5000/admin/>`_, Here, both the *name* and *template_mode* parameters are optional. If you start this application and navigate to `http://localhost:5000/admin/ <http://localhost:5000/admin/>`_,
you should see an empty "Home" page with a navigation bar on top, and the *name* that you specified. you should see an empty "Home" page with a navigation bar on top, and the *name* that you specified.
.. note::
As an alternative to passing a Flask application object to the Admin constructor, you can also call the
:meth:`~flask_admin.base.Admin.init_app` function, after the Admin instance has been initialized::
admin = Admin(name='My App', template_mode='bootstrap3')
# Add views here
admin.init_app(app)
Adding Model Views Adding Model Views
----------- -----------
Model views allow you to add dedicated admin pages for each of the models in your database. Do this by creating Model views allow you to add a dedicated set of admin pages for any model in your database. Do this by creating
instances of the *ModelView* class, which you can import from one of Flask-Admin's built-in ORM backends. An example instances of the *ModelView* class, which you can import from one of Flask-Admin's built-in ORM backends. An example
is the SQLAlchemy backend, which you can use as follows:: is the SQLAlchemy backend, which you can use as follows::
...@@ -54,10 +45,9 @@ is the SQLAlchemy backend, which you can use as follows:: ...@@ -54,10 +45,9 @@ is the SQLAlchemy backend, which you can use as follows::
Straight out of the box, this gives you a set of fully featured *CRUD* views for your model: Straight out of the box, this gives you a set of fully featured *CRUD* views for your model:
* A list view, with support for searching, sorting and filtering * A `list` view, with support for searching, sorting and filtering and deleting records.
* a view for adding new records * A `create` view for adding new records.
* a view for editing existing records * An `edit` view for updating existing records.
* the ability to delete records.
There are many options available for customizing the display and functionality of these builtin view. There are many options available for customizing the display and functionality of these builtin view.
For more details on that, see :ref:`customising-builtin-views`. For more details on that, see :ref:`customising-builtin-views`.
...@@ -73,4 +63,4 @@ is that it's just an empty page with a navigation menu. To add some content to t ...@@ -73,4 +63,4 @@ is that it's just an empty page with a navigation menu. To add some content to t
<p>Hello world</p> <p>Hello world</p>
{% endblock %} {% endblock %}
This will override the builtin index template, but still give you the builtin navigation menu. This will override the builtin index template, but still give you the builtin navigation menu. So, now you can add any content to the index page that makes sense for your app.
...@@ -20,7 +20,7 @@ Examples ...@@ -20,7 +20,7 @@ Examples
-------- --------
Flask-Admin comes with several examples that will help you get a grip on what's possible. Flask-Admin comes with several examples that will help you get a grip on what's possible.
Have a look at http://examples.flask-admin.org/ to see them in action, or browse through the example code in the `GitHub repository <http://github.com/flask-admin/flask-admin>`_. Have a look at http://examples.flask-admin.org/ to see them in action, or browse through the `examples` directory in the GitHub repository.
User Guide User Guide
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment