The first step, is to initialise an empty admin interface on your Flask app::
The first step, is to initialise an empty admin interface on your Flask app::
...
@@ -30,7 +30,7 @@ If you start this application and navigate to `http://localhost:5000/admin/ <htt
...
@@ -30,7 +30,7 @@ If you start this application and navigate to `http://localhost:5000/admin/ <htt
you should see an empty page with a navigation bar on top.
you should see an empty page with a navigation bar on top.
Adding Model Views
Adding Model Views
----------------------
------------------
Model views allow you to add a dedicated set of admin pages for managing any model in your database. Do this by creating
Model views allow you to add a dedicated set of admin pages for managing 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
...
@@ -55,7 +55,7 @@ For more details on that, see :ref:`customising-builtin-views`. For more details
...
@@ -55,7 +55,7 @@ For more details on that, see :ref:`customising-builtin-views`. For more details
ORM backends that are available, see :ref:`database-backends`.
ORM backends that are available, see :ref:`database-backends`.
Enabling CSRF Validation
Enabling CSRF Validation
-----------------------------
------------------------
To add CSRF protection to the forms that are generated by *ModelView* instances, use the
To add CSRF protection to the forms that are generated by *ModelView* instances, use the
`FlaskWTF <https://flask-wtf.readthedocs.org/>`_ form class in your *ModelView*
`FlaskWTF <https://flask-wtf.readthedocs.org/>`_ form class in your *ModelView*
...
@@ -76,7 +76,7 @@ The FlaskWTF form class comes with CSRF protection builtin, so it will generate
...
@@ -76,7 +76,7 @@ The FlaskWTF form class comes with CSRF protection builtin, so it will generate
the tokens for you, and validate them when the forms are submitted.
the tokens for you, and validate them when the forms are submitted.
Adding Content to the Index Page
Adding Content to the Index Page
------------------------------------
--------------------------------
The first thing you'll notice when you visit `http://localhost:5000/admin/ <http://localhost:5000/admin/>`_
The first thing you'll notice when you visit `http://localhost:5000/admin/ <http://localhost:5000/admin/>`_
is that it's just an empty page with a navigation menu. To add some content to this page, save the following text as `admin/index.html` in your project's `templates` directory::
is that it's just an empty page with a navigation menu. To add some content to this page, save the following text as `admin/index.html` in your project's `templates` directory::
...
@@ -90,7 +90,7 @@ This will override the default index template, but still give you the builtin na
...
@@ -90,7 +90,7 @@ This will override the default index template, but still give you the builtin na
So, now you can add any content to the index page, while maintaining a consistent user experience.
So, now you can add any content to the index page, while maintaining a consistent user experience.
Authorisation & Permissions
Authorisation & Permissions
=================================
===========================
****
****
...
@@ -99,7 +99,7 @@ you'll want to solve is how to keep unwanted users out. With Flask-Admin there
...
@@ -99,7 +99,7 @@ you'll want to solve is how to keep unwanted users out. With Flask-Admin there
are a few different ways of approaching this.
are a few different ways of approaching this.
HTTP Basic Auth
HTTP Basic Auth
------------------------
---------------
The simplest form of authentication is HTTP Basic Auth. It doesn't interfere
The simplest form of authentication is HTTP Basic Auth. It doesn't interfere
with your database models, and it doesn't require you to write any new view logic or
with your database models, and it doesn't require you to write any new view logic or
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
...
@@ -112,7 +112,7 @@ Unfortunately, there is no easy way of applying HTTP Basic Auth just to your adm
...
@@ -112,7 +112,7 @@ Unfortunately, there is no easy way of applying HTTP Basic Auth just to your adm
interface.
interface.
Rolling Your Own
Rolling Your Own
--------------------------------
----------------
For a more flexible solution, Flask-Admin lets you define access control rules
For a more flexible 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
...
@@ -138,7 +138,7 @@ registration and account management views yourself.
...
@@ -138,7 +138,7 @@ registration and account management views yourself.
Using Flask-Security
Using Flask-Security
--------------------------------
--------------------
If you want a more polished solution, you could
If you want a more polished solution, you could
use `Flask-Security <https://pythonhosted.org/Flask-Security/>`_,
use `Flask-Security <https://pythonhosted.org/Flask-Security/>`_,
...
@@ -173,7 +173,7 @@ approach for including the other views, like `forgot_password`, `send_confirmati
...
@@ -173,7 +173,7 @@ approach for including the other views, like `forgot_password`, `send_confirmati
.. _customising-builtin-views:
.. _customising-builtin-views:
Customising Builtin Views
Customising Builtin Views
=================================
=========================
****
****
...
@@ -209,7 +209,7 @@ Or, in much the same way, you can specify options for a single model at a time::
...
@@ -209,7 +209,7 @@ Or, in much the same way, you can specify options for a single model at a time::
`ModelView` Configuration Attributes
`ModelView` Configuration Attributes
-------------------------------------
------------------------------------
For a complete list of the attributes that are defined, have a look at the
For a complete list of the attributes that are defined, have a look at the
API documentation for :meth:`~flask_admin.model.BaseModelView`. Here follows
API documentation for :meth:`~flask_admin.model.BaseModelView`. Here follows
...
@@ -293,7 +293,7 @@ These inline forms can be customised. Have a look at the API documentation for
...
@@ -293,7 +293,7 @@ These inline forms can be customised. Have a look at the API documentation for