Commit bacb38c9 authored by Petrus J.v.Rensburg's avatar Petrus J.v.Rensburg

Merge branch 'master' of github.com:mrjoes/flask-admin into examples

parents a837b83e 9208f58d
...@@ -23,7 +23,8 @@ Out-of-the-box, Flask-Admin plays nicely with various ORM's, including ...@@ -23,7 +23,8 @@ Out-of-the-box, Flask-Admin plays nicely with various ORM's, including
It also boasts a simple file management interface and a `redis client <http://redis.io/>`_ console. It also boasts a simple file management interface and a `redis client <http://redis.io/>`_ console.
Several usage examples are included in the */examples* folder. Feel free to add your own examples, or improve some of the existing ones, and submit them as a *pull-request*. Several usage examples are included in the */examples* folder. Please feel free to add your own examples, or improve
on some of the existing ones, and then submit them via GitHub as a *pull-request*.
The biggest feature of Flask-Admin is flexibility. It aims to provide a set of simple tools that can be used for The biggest feature of Flask-Admin is flexibility. It aims to provide a set of simple tools that can be used for
building admin interfaces of any complexity. So, to start off with you can create a very simple application in no time, building admin interfaces of any complexity. So, to start off with you can create a very simple application in no time,
...@@ -36,7 +37,8 @@ Documentation ...@@ -36,7 +37,8 @@ Documentation
------------- -------------
Flask-Admin is extensively documented, you can find all of the documentation at `http://readthedocs.org/docs/flask-admin <http://readthedocs.org/docs/flask-admin>`_. Flask-Admin is extensively documented, you can find all of the documentation at `http://readthedocs.org/docs/flask-admin <http://readthedocs.org/docs/flask-admin>`_.
The docs are auto-generated for the *.rst* files in the */doc* folder. So if you come across any errors, or think of anything that should be included, then please make the changes and submit them as a *pull-request*. The docs are auto-generated from the *.rst* files in the */doc* folder. So if you come across any errors, or
if you think of anything else that should be included, then please make the changes and submit them as a *pull-request*.
Installation Installation
------------ ------------
...@@ -63,8 +65,9 @@ and then:: ...@@ -63,8 +65,9 @@ and then::
cd flask-admin cd flask-admin
nosetests nosetests
You should see output such as:: You should see output similar to::
...
---------------------------------------------------------------------- ----------------------------------------------------------------------
Ran 41 tests in 2.092s Ran 41 tests in 2.092s
......
...@@ -4,7 +4,7 @@ Changelog ...@@ -4,7 +4,7 @@ Changelog
1.0.7 1.0.7
----- -----
Full change log and feature walkthrough can be found `here <http://mrjoes.github.io/2013/03/22/flask-admin-107.html>`_. Full change log and feature walkthrough can be found `here <http://mrjoes.github.io/2013/10/21/flask-admin-107.html>`_.
Highlights: Highlights:
......
Database backends Database backends
================= =================
The purpose of Flask-Admin is to help you manage your data. For this, it needs some database backend in order to be
able to access that data in the first place. At present, there are four different backends for you to choose
from, depending on which database you would like to use for your application.
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
...@@ -8,3 +12,17 @@ Database backends ...@@ -8,3 +12,17 @@ Database backends
db_mongoengine db_mongoengine
db_peewee db_peewee
db_pymongo db_pymongo
If you don't know where to start, but you're familiar with relational databases, then you should probably look at using
`SQLAlchemy <http://www.sqlalchemy.org/>`_. It is a full-featured toolkit, with support for SQLite, PostgreSQL, MySQL,
Oracle and MS-SQL amongst others. It really comes into its own once you have lots of data, and a fair amount of
relations between your data models.
If you're looking for something simpler, or your data models are reasonably self-contained, then
`MongoEngine <http://mongoengine.org/>`_ could be a better option. It is a python wrapper around the popular
*NoSQL* database called `MongoDB <http://www.mongodb.org/>`_.
Of course, if you feel that there's an awesome database wrapper that is missing from the list above, we'd greatly
appreciate it if you could write the plugin for it and submit it as a pull request. A special section of these docs
are dedicated to helping you through this process. See :doc:`model_guidelines`.
Form rendering rules Form rendering rules
-------------------- ====================
Before version 1.0.7, all model backends were rendering the creation and editing forms Before version 1.0.7, all model backends were rendering the *create* and *edit* forms
using the special Jinja2 macro, which was looping over WTForms form object fields and displaying using a special Jinja2 macro, which was looping over the fields of a WTForms form object and displaying
them one by one. them one by one. This works well, but it is difficult to customize.
Starting from version 1.0.7, Flask-Admin supports so called form rendering rules. 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.
Idea is pretty simple: instead of having non-configurable macro that renders the form, The basic idea is pretty simple: the customizable rendering rules replace a static macro, so that you can tell
have a set of rules that tell Flask-Admin how form should be rendered. As an extension Flask-Admin how each form should be rendered. As an extension, however, the rendering rules also let you do a
of the idea, rules can 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 form rendering away from the form definition. And it Essentially, form rendering rules abstract the rendering, so that it becomes separate from the form definition. So,
no longer matters what is sequence of the fields in the form. for example, it no longer matters in which sequence yur form fields are defined.
Getting started Getting started
--------------- ---------------
To start using form rendering rules, you need to put list of form field names into `form_create_rules` To start using the form rendering rules, put a list of form field names into the `form_create_rules`
property of your administrative view:: property one of your admin views::
class RuleView(sqla.ModelView): class RuleView(sqla.ModelView):
form_create_rules = ('email', 'first_name', 'last_name') form_create_rules = ('email', 'first_name', 'last_name')
In this example, only three fields will be rendered and `email` field will be above other two fields. In this example, only three fields will be rendered and `email` field will be above other two fields.
Whenever Flask-Admin sees string as a value in `form_create_rules`, it automatically assumes that it is Whenever Flask-Admin sees a string value in `form_create_rules`, it automatically assumes that it is a
form field reference and created :class:`flask.ext.admin.form.rules.Field` class instance. form field reference and creates a :class:`flask.ext.admin.form.rules.Field` class instance for that field.
Lets say we want to display 'Foobar' text between `email` and `first_name` fields. This can be accomplished by Lets say we want to display some text between the `email` and `first_name` fields. This can be accomplished by
using :class:`flask.ext.admin.form.rules.Text` class:: using the :class:`flask.ext.admin.form.rules.Text` class::
from flask.ext.admin.form import rules from flask.ext.admin.form import rules
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')
Flask-Admin comes with few built-in rules that can be found in :mod:`flask.ext.admin.form.rules` module: Built-in rules
--------------
Flask-Admin comes with few built-in rules that can be found in the :mod:`flask.ext.admin.form.rules` module:
======================================================= ========================================================
Form Rendering Rule Description
======================================================= ======================================================== ======================================================= ========================================================
:class:`flask.ext.admin.form.rules.BaseRule` All rules derive from this class :class:`flask.ext.admin.form.rules.BaseRule` All rules derive from this class
:class:`flask.ext.admin.form.rules.NestedRule` Allows rule nesting, useful for HTML containers :class:`flask.ext.admin.form.rules.NestedRule` Allows rule nesting, useful for HTML containers
...@@ -50,5 +56,8 @@ Flask-Admin comes with few built-in rules that can be found in :mod:`flask.ext.a ...@@ -50,5 +56,8 @@ Flask-Admin comes with few built-in rules that can be found in :mod:`flask.ext.a
:class:`flask.ext.admin.form.rules.FieldSet` Renders form header and child rules :class:`flask.ext.admin.form.rules.FieldSet` Renders form header and child rules
======================================================= ======================================================== ======================================================= ========================================================
Further reading
---------------
For additional documentation, check :mod:`flask.ext.admin.form.rules` module source code (it is quite short) and For additional documentation, check :mod:`flask.ext.admin.form.rules` module source code (it is quite short) and
look at the `forms` example. look at the `forms example <https://github.com/mrjoes/flask-admin/tree/master/examples/forms>`_ on GitHub.
...@@ -17,8 +17,8 @@ Browse through the documentation below to learn more about what you can do with ...@@ -17,8 +17,8 @@ Browse through the documentation below to learn more about what you can do with
localization localization
tips tips
db db
form_rules
model_guidelines model_guidelines
form_rules
api/index api/index
changelog changelog
renamed_columns renamed_columns
......
...@@ -187,8 +187,8 @@ ...@@ -187,8 +187,8 @@
}; };
}; };
// Add live event handler // Add on event handler
$('.fa-remove-field').live('click', function(e) { $('body').on('click', '.fa-remove-field' , function(e) {
e.preventDefault(); e.preventDefault();
var form = $(this).closest('.fa-inline-field'); var form = $(this).closest('.fa-inline-field');
......
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