Commit 4190e319 authored by Petrus J.v.Rensburg's avatar Petrus J.v.Rensburg

Fix heading format and use consistent capitalization throughout.

parent 0cc13aba
.. _adding-model-backend: .. _adding-model-backend:
Adding a Model Backend Adding A Model Backend
========================== ======================
Flask-Admin makes a few assumptions about the database models that it works with. If you want to implement your own Flask-Admin makes a few assumptions about the database models that it works with. If you want to implement your own
database backend, and still have Flask-Admin's model views work as expected, then you should take note of the following: database backend, and still have Flask-Admin's model views work as expected, then you should take note of the following:
...@@ -14,7 +14,7 @@ If that is the case, then you can implement your own database backend by extendi ...@@ -14,7 +14,7 @@ If that is the case, then you can implement your own database backend by extendi
and implementing the set of scaffolding methods listed below. and implementing the set of scaffolding methods listed below.
Extending BaseModelView Extending BaseModelView
------------------------- -----------------------
Start off by defining a new class, which derives from from :class:`~flask_admin.model.BaseModelView`:: Start off by defining a new class, which derives from from :class:`~flask_admin.model.BaseModelView`::
......
:tocdepth: 2 :tocdepth: 2
Advanced Functionality Advanced Functionality
================================= ======================
Localization With Flask-Babelex Localization With Flask-Babelex
------------------------------------------ -------------------------------
**** ****
...@@ -45,7 +45,7 @@ to see how you can add your own. ...@@ -45,7 +45,7 @@ to see how you can add your own.
.. _file-admin: .. _file-admin:
Managing Files & Folders Managing Files & Folders
-------------------------------- ------------------------
**** ****
...@@ -67,8 +67,8 @@ can use it by adding a FileAdmin view to your app:: ...@@ -67,8 +67,8 @@ can use it by adding a FileAdmin view to your app::
You can disable uploads, disable file deletion, restrict file uploads to certain types, etc. You can disable uploads, disable file deletion, restrict file uploads to certain types, etc.
Check :mod:`flask_admin.contrib.fileadmin` in the API documentation for more details. Check :mod:`flask_admin.contrib.fileadmin` in the API documentation for more details.
Adding a Redis Console Adding A Redis Console
-------------------------- ----------------------
**** ****
...@@ -87,7 +87,7 @@ instance running on the same machine as your app, you can:: ...@@ -87,7 +87,7 @@ instance running on the same machine as your app, you can::
Replacing Individual Form Fields Replacing Individual Form Fields
------------------------------------------ --------------------------------
**** ****
...@@ -96,7 +96,7 @@ A common use-case for this would be to add a *What-You-See-Is-What-You-Get* (WYS ...@@ -96,7 +96,7 @@ A common use-case for this would be to add a *What-You-See-Is-What-You-Get* (WYS
file / image uploads that need to be tied to a field in your model. file / image uploads that need to be tied to a field in your model.
WYSIWIG Text Fields WYSIWIG Text Fields
********************** *******************
To handle complicated text content, you can use To handle complicated text content, you can use
`CKEditor <http://ckeditor.com/>`_ by subclassing some of the builtin WTForms `CKEditor <http://ckeditor.com/>`_ by subclassing some of the builtin WTForms
classes as follows:: classes as follows::
...@@ -152,7 +152,7 @@ If you just want to manage static files in a directory, without tying them to a ...@@ -152,7 +152,7 @@ If you just want to manage static files in a directory, without tying them to a
rather use the handy :ref:`File-Admin<file-admin>` plugin. rather use the handy :ref:`File-Admin<file-admin>` plugin.
Managing Geographical Models Managing Geographical Models
------------------------------------------- ----------------------------
**** ****
...@@ -194,7 +194,7 @@ Have a look at https://github.com/flask-admin/flask-admin/tree/master/examples/g ...@@ -194,7 +194,7 @@ Have a look at https://github.com/flask-admin/flask-admin/tree/master/examples/g
to get started. to get started.
Loading Tiles From Mapbox Loading Tiles From Mapbox
************************************** *************************
To have map data display correctly, you'll have to sign up for an account at https://www.mapbox.com/ To have map data display correctly, you'll have to sign up for an account at https://www.mapbox.com/
and include some credentials in your application's config:: and include some credentials in your application's config::
...@@ -209,14 +209,14 @@ at the moment, Flask-Admin only supports Mapbox. If you want to use other ...@@ -209,14 +209,14 @@ at the moment, Flask-Admin only supports Mapbox. If you want to use other
providers, make a pull request! providers, make a pull request!
Limitations Limitations
******************* ***********
There's currently no way to sort, filter, or search on geometric fields There's currently no way to sort, filter, or search on geometric fields
in the admin. It's not clear that there's a good way to do so. in the admin. It's not clear that there's a good way to do so.
If you have any ideas or suggestions, make a pull request! If you have any ideas or suggestions, make a pull request!
Customising Builtin Forms via Rendering Rules Customising Builtin Forms Via Rendering Rules
-------------------------------------------------------- ---------------------------------------------
**** ****
...@@ -253,8 +253,8 @@ using the :class:`flask_admin.form.rules.Text` class:: ...@@ -253,8 +253,8 @@ using the :class:`flask_admin.form.rules.Text` class::
class RuleView(sqla.ModelView): class RuleView(sqla.ModelView):
form_create_rules = ('email', rules.Text('Foobar'), 'first_name', 'last_name') form_create_rules = ('email', rules.Text('Foobar'), 'first_name', 'last_name')
Built-in rules Built-in Rules
******************* **************
Flask-Admin comes with few built-in rules that can be found in the :mod:`flask_admin.form.rules` module: Flask-Admin comes with few built-in rules that can be found in the :mod:`flask_admin.form.rules` module:
...@@ -275,7 +275,7 @@ Form Rendering Rule Description ...@@ -275,7 +275,7 @@ Form Rendering Rule Description
.. _database-backends: .. _database-backends:
Using Different Database Backends Using Different Database Backends
---------------------------------------- ---------------------------------
**** ****
...@@ -290,7 +290,7 @@ relations between your data models. If you want to track spatial data like latit ...@@ -290,7 +290,7 @@ relations between your data models. If you want to track spatial data like latit
points, you should look into `GeoAlchemy`_, as well. points, you should look into `GeoAlchemy`_, as well.
SQLAlchemy SQLAlchemy
******************** **********
Notable features: Notable features:
...@@ -338,7 +338,7 @@ a proper error message and you can change the data in the form. When the applica ...@@ -338,7 +338,7 @@ a proper error message and you can change the data in the form. When the applica
the ``werkzeug`` debugger will catch the exception and will display the stacktrace. the ``werkzeug`` debugger will catch the exception and will display the stacktrace.
MongoEngine MongoEngine
********************* ***********
If you're looking for something simpler than SQLAlchemy, and your data models If you're looking for something simpler than SQLAlchemy, and your data models
are reasonably self-contained, then `MongoDB <https://www.mongodb.org/>`_, a popular *NoSQL* database, are reasonably self-contained, then `MongoDB <https://www.mongodb.org/>`_, a popular *NoSQL* database,
...@@ -368,7 +368,7 @@ Known issues: ...@@ -368,7 +368,7 @@ Known issues:
For more, check the :class:`~flask_admin.contrib.mongoengine` API documentation. For more, check the :class:`~flask_admin.contrib.mongoengine` API documentation.
Peewee Peewee
***************** ******
Features: Features:
...@@ -387,7 +387,7 @@ For more, check the :class:`~flask_admin.contrib.peewee` API documentation. Or l ...@@ -387,7 +387,7 @@ For more, check the :class:`~flask_admin.contrib.peewee` API documentation. Or l
the Peewee example at https://github.com/flask-admin/flask-admin/tree/master/examples/peewee. the Peewee example at https://github.com/flask-admin/flask-admin/tree/master/examples/peewee.
PyMongo PyMongo
***************** *******
The bare minimum you have to provide for Flask-Admin to work with PyMongo: The bare minimum you have to provide for Flask-Admin to work with PyMongo:
...@@ -417,7 +417,7 @@ For more, check the :class:`~flask_admin.contrib.pymongoe` API documentation. Or ...@@ -417,7 +417,7 @@ For more, check the :class:`~flask_admin.contrib.pymongoe` API documentation. Or
the Peewee example at https://github.com/flask-admin/flask-admin/tree/master/examples/pymongo. the Peewee example at https://github.com/flask-admin/flask-admin/tree/master/examples/pymongo.
Migrating From Django Migrating From Django
------------------------- ---------------------
**** ****
...@@ -425,7 +425,7 @@ If you are used to `Django <https://www.djangoproject.com/>`_ and the *django-ad ...@@ -425,7 +425,7 @@ If you are used to `Django <https://www.djangoproject.com/>`_ and the *django-ad
Flask-Admin to work slightly different from what you would expect. Flask-Admin to work slightly different from what you would expect.
Design Philosophy Design Philosophy
**************************** *****************
In general, Django and *django-admin* strives to make life easier by implementing sensible defaults. So a developer In general, Django and *django-admin* strives to make life easier by implementing sensible defaults. So a developer
will be able to get an application up in no time, but it will have to conform to most of the defaults. Of course it will be able to get an application up in no time, but it will have to conform to most of the defaults. Of course it
...@@ -473,8 +473,8 @@ backends) and specific backend documentation, for example ...@@ -473,8 +473,8 @@ backends) and specific backend documentation, for example
:class:`~flask_admin.contrib.sqla.ModelView`. There's much more :class:`~flask_admin.contrib.sqla.ModelView`. There's much more
than what is displayed in this table. than what is displayed in this table.
Overriding the Form Scaffolding Overriding The Form Scaffolding
--------------------------------- -------------------------------
**** ****
......
:tocdepth: 2 :tocdepth: 2
Flask-Admin Flask-Admin
########################################## ###########
**Why Flask?** As a micro-framework, `Flask <http://flask.pocoo.org/>`_ lets you build web services with very little overhead. **Why Flask?** As a micro-framework, `Flask <http://flask.pocoo.org/>`_ lets you build web services with very little overhead.
It offers freedom for you, the designer, to implement your project in a way that suits your It offers freedom for you, the designer, to implement your project in a way that suits your
...@@ -37,13 +37,13 @@ directory in the `GitHub repository <https://github.com/flask-admin/flask-admin> ...@@ -37,13 +37,13 @@ directory in the `GitHub repository <https://github.com/flask-admin/flask-admin>
changelog changelog
Support Support
---------- -------
**** ****
Python 2.6 - 2.7 and 3.3 - 3.4. Python 2.6 - 2.7 and 3.3 - 3.4.
Indices and tables Indices And Tables
------------------ ------------------
**** ****
......
:tocdepth: 2 :tocdepth: 2
Introduction to Flask-Admin Introduction To Flask-Admin
########################################## ###########################
Getting Started Getting Started
================ ===============
**** ****
Initialization Initialization
------------------- --------------
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
:meth:`~flask_admin.contrib.sqla.ModelView.inline_models`. :meth:`~flask_admin.contrib.sqla.ModelView.inline_models`.
Adding Your Own Views Adding Your Own Views
====================== =====================
**** ****
...@@ -302,7 +302,7 @@ them with the builtin :class:`~flask_admin.model.ModelView` class, Flask-Admin m ...@@ -302,7 +302,7 @@ them with the builtin :class:`~flask_admin.model.ModelView` class, Flask-Admin m
take full control and add your own views to the interface. take full control and add your own views to the interface.
Standalone Views Standalone Views
------------------ ----------------
A set of standalone views, that are not tied to any particular model, can be added by extending the A set of standalone views, that are not tied to any particular model, can be added by extending the
:class:`~flask_admin.base.BaseView` class, and defining your own view methods on it. For :class:`~flask_admin.base.BaseView` class, and defining your own view methods on it. For
example, to add a page that displays some analytics data from a 3rd-party API:: example, to add a page that displays some analytics data from a 3rd-party API::
...@@ -331,8 +331,8 @@ The `analytics_index.html` template for the example above, could look something ...@@ -331,8 +331,8 @@ The `analytics_index.html` template for the example above, could look something
By extending the *admin/master.html* template, you can maintain a consistent user experience, By extending the *admin/master.html* template, you can maintain a consistent user experience,
even while having tight control over your page's content. even while having tight control over your page's content.
Overriding the Builtin Views Overriding The Builtin Views
------------------------------------ ----------------------------
There may be some scenarios where you want most of the builtin ModelView There may be some scenarios where you want most of the builtin ModelView
functionality, but you want to replace one of the default `create`, `edit`, or `list` views. functionality, but you want to replace one of the default `create`, `edit`, or `list` views.
For this you could override only the view in question, and all the links to it will still function as you would expect:: For this you could override only the view in question, and all the links to it will still function as you would expect::
...@@ -350,15 +350,15 @@ For this you could override only the view in question, and all the links to it w ...@@ -350,15 +350,15 @@ For this you could override only the view in question, and all the links to it w
return self.render('create_user.html') return self.render('create_user.html')
Working with the builtin templates Working With The Builtin Templates
==================================== ==================================
**** ****
Flask-Admin uses the `Jinja2 <http://jinja.pocoo.org/docs/>`_ templating engine. Flask-Admin uses the `Jinja2 <http://jinja.pocoo.org/docs/>`_ templating engine.
Overriding the Builtin Templates Overriding The Builtin Templates
--------------------------------- --------------------------------
To take full control over the style and layout of the admin interface, you can override To take full control over the style and layout of the admin interface, you can override
all of the builtin templates. Just keep in mind that the templates will change slightly all of the builtin templates. Just keep in mind that the templates will change slightly
...@@ -372,8 +372,8 @@ automatically take precedence over the builtin ones. ...@@ -372,8 +372,8 @@ automatically take precedence over the builtin ones.
.. _extending-builtin-templates: .. _extending-builtin-templates:
Extending the Builtin Templates Extending The Builtin Templates
--------------------------------- -------------------------------
Rather than overriding the builtin templates completely, you could extend them. This Rather than overriding the builtin templates completely, you could extend them. This
could make it simpler for you to upgrade to new Flask Admin versions in future. could make it simpler for you to upgrade to new Flask Admin versions in future.
...@@ -408,7 +408,7 @@ the admin constructor during initialization:: ...@@ -408,7 +408,7 @@ the admin constructor during initialization::
admin = Admin(app, base_template='microblog_master.html') admin = Admin(app, base_template='microblog_master.html')
Available Template Blocks Available Template Blocks
**************************** *************************
Flask-Admin defines one *base* template at `admin/master.html` that all the other admin templates are derived Flask-Admin defines one *base* template at `admin/master.html` that all the other admin templates are derived
from. This template is a proxy which points to `admin/base.html`, which defines from. This template is a proxy which points to `admin/base.html`, which defines
...@@ -449,7 +449,7 @@ empty_list_message Message that will be displayed if there are no models fo ...@@ -449,7 +449,7 @@ empty_list_message Message that will be displayed if there are no models fo
Have a look at the `layout` example at https://github.com/flask-admin/flask-admin/tree/master/examples/layout Have a look at the `layout` example at https://github.com/flask-admin/flask-admin/tree/master/examples/layout
to see how you can take full stylistic control over the admin interface. to see how you can take full stylistic control over the admin interface.
Environment variables Environment Variables
--------------------- ---------------------
While working in any of the templates that extend `admin/master.html`, you have access to a small number of While working in any of the templates that extend `admin/master.html`, you have access to a small number of
...@@ -466,7 +466,7 @@ h Helpers from :mod:`~flask_admin.helpers` module ...@@ -466,7 +466,7 @@ h Helpers from :mod:`~flask_admin.helpers` module
==================== ================================ ==================== ================================
Generating URLs Generating URLs
------------------ ---------------
To generate the URL for a specific view, use *url_for* with a dot prefix:: To generate the URL for a specific view, use *url_for* with a dot prefix::
......
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