If you are using the MongoEngine backend, Flask-Admin supports GridFS-backed image- and file uploads, done through WTForms fields. Documentation can be found
If you are using the MongoEngine backend, Flask-Admin supports GridFS-backed image and file uploads through WTForms fields. Documentation can be found at :mod:`flask_admin.contrib.mongoengine.fields`.
at :mod:`flask_admin.contrib.mongoengine.fields`.
If you just want to manage static files in a directory, without tying them to a database model, then
If you just want to manage static files in a directory, without tying them to a database model, then
rather use the handy :ref:`File-Admin<file-admin>` plugin.
use the :ref:`File-Admin<file-admin>` plug-in.
Managing Geographical Models
Managing Geographical Models
----------------------------
----------------------------
...
@@ -172,8 +171,7 @@ Managing Geographical Models
...
@@ -172,8 +171,7 @@ Managing Geographical Models
****
****
If you want to store spatial information in a GIS database, Flask-Admin has
If you want to store spatial information in a GIS database, Flask-Admin has
you covered. The GeoAlchemy backend
you covered. The GeoAlchemy backend extends the SQLAlchemy backend (just as
extends the SQLAlchemy backend (just as
`GeoAlchemy <http://geoalchemy-2.readthedocs.org/>`_ extends SQLAlchemy) to give you a pretty and functional map-based
`GeoAlchemy <http://geoalchemy-2.readthedocs.org/>`_ extends SQLAlchemy) to give you a pretty and functional map-based
editor for your admin pages.
editor for your admin pages.
...
@@ -188,7 +186,7 @@ Some notable features include:
...
@@ -188,7 +186,7 @@ Some notable features include:
- Works with a `Geometry <http://geoalchemy-2.readthedocs.org/en/latest/types.html#geoalchemy2.types.Geometry>`_ SQL field that is integrated with `Shapely <http://toblerity.org/shapely/>`_ objects.
- Works with a `Geometry <http://geoalchemy-2.readthedocs.org/en/latest/types.html#geoalchemy2.types.Geometry>`_ SQL field that is integrated with `Shapely <http://toblerity.org/shapely/>`_ objects.
To get started, define some fields on your model using GeoAlchemy's *Geometry*
To get started, define some fields on your model using GeoAlchemy's *Geometry*
field. An then, add model views to your interface using the ModelView class
field. Next, add model views to your interface using the ModelView class
from the GeoAlchemy backend, rather than the usual SQLAlchemy backend::
from the GeoAlchemy backend, rather than the usual SQLAlchemy backend::
from geoalchemy2 import Geometry
from geoalchemy2 import Geometry
...
@@ -242,12 +240,12 @@ them one by one. This works well, but it is difficult to customize.
...
@@ -242,12 +240,12 @@ them one by one. This works well, but it is difficult to customize.
Starting from version 1.0.7, Flask-Admin supports form rendering rules, to give you fine grained control of how
Starting from version 1.0.7, Flask-Admin supports form rendering rules, to give you fine grained control of how
the forms for your modules should be displayed.
the forms for your modules should be displayed.
The basic idea is pretty simple: the customizable rendering rules replace a static macro, so that you can tell
The basic idea is pretty simple: the customizable rendering rules replace a static macro, so you can tell
Flask-Admin how each form should be rendered. As an extension, however, the rendering rules also let you do a
Flask-Admin how each form should be rendered. As an extension, however, the rendering rules also let you do a
bit more: You can use them to output HTML, call Jinja2 macros, render fields and so on.
bit more: You can use them to output HTML, call Jinja2 macros, render fields, and so on.
Essentially, form rendering rules abstract the rendering, so that it becomes separate from the form definition. So,
Essentially, form rendering rules separate the form rendering from the form definition.
for example, it no longer matters in which sequence your form fields are defined.
For example, it no longer matters in which sequence your form fields are defined.
To start using the form rendering rules, put a list of form field names into the `form_create_rules`
To start using the form rendering rules, put a list of form field names into the `form_create_rules`
property one of your admin views::
property one of your admin views::
...
@@ -260,7 +258,7 @@ In this example, only three fields will be rendered and `email` field will be ab
...
@@ -260,7 +258,7 @@ In this example, only three fields will be rendered and `email` field will be ab
Whenever Flask-Admin sees a string value in `form_create_rules`, it automatically assumes that it is a
Whenever Flask-Admin sees a string value in `form_create_rules`, it automatically assumes that it is a
form field reference and creates a :class:`flask_admin.form.rules.Field` class instance for that field.
form field reference and creates a :class:`flask_admin.form.rules.Field` class instance for that field.
Lets say we want to display some text between the `email` and `first_name` fields. This can be accomplished by
Let's say we want to display some text between the `email` and `first_name` fields. This can be accomplished by
using the :class:`flask_admin.form.rules.Text` class::
using the :class:`flask_admin.form.rules.Text` class::
from flask_admin.form import rules
from flask_admin.form import rules
...
@@ -320,7 +318,7 @@ Flask-Admin has limited support for models with multiple primary keys. It only c
...
@@ -320,7 +318,7 @@ Flask-Admin has limited support for models with multiple primary keys. It only c
all but one primary keys are foreign keys to another model. For example, model inheritance following
all but one primary keys are foreign keys to another model. For example, model inheritance following
this convention.
this convention.
Lets Model a car with its tyres::
Let's Model a car with its tyres::
class Car(db.Model):
class Car(db.Model):
__tablename__ = 'cars'
__tablename__ = 'cars'
...
@@ -488,7 +486,7 @@ backends) and specific backend documentation, for example
...
@@ -488,7 +486,7 @@ 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