Commit f51b56ab authored by Serge S. Koval's avatar Serge S. Koval

Doc fixes. Fixed #267

parent ee966c12
...@@ -4,33 +4,38 @@ Usage Tips ...@@ -4,33 +4,38 @@ Usage Tips
General tips General tips
------------ ------------
1. Whenever your administrative views share common functionality such as authentication, 1. Whenever your administrative views share common functionality such as authentication,
form validation, make use of read-only views and so on - create your own base class which form validation, make use of read-only views and so on - create your own base class which
inherits from proper Flask-Admin view class. inherits from proper Flask-Admin view class.
For example, if you need to check user permissions for every call, don't implement For example, if you need to check user permissions for every call, don't implement
`is_accessible` in every administrative view. Create your own base class, implement `is_accessible` in every administrative view. Create your own base class, implement
`is_accessible` there and use this class for all your views. `is_accessible` there and use this class for all your views.
2. You can override used templates either by using `ModelView` properties (such as 2. You can override used templates either by using `ModelView` properties (such as
`list_template`, `create_template`, `edit_template`) or `list_template`, `create_template`, `edit_template`) or
putting customized version of the template into your `templates/admin/` directory putting customized version of the template into your `templates/admin/` directory
3. If you need to customize look and feel of model forms, there are two options: 3. If you need to customize look and feel of model forms, there are two options:
- Override create/edit template
- Use new :mod:`flask.ext.admin.form.rules` form rendering rules
- Override create/edit template 4. Flask-Admin has that manage file/image uploads and store result in model field. You can
- Use new :mod:`flask.ext.admin.form.rules` form rendering rules find documentation here :mod:`flask.ext.admin.form.upload`.
4. Flask-Admin has that manage file/image uploads and store result in model field. You can 5. If you don't want to use Flask-Admin form scaffolding logic, you can override
find documentation here - :mod:`flask.ext.admin.form.upload`. :meth:`~flask.ext.admin.model.base.scaffold_form` and put your own form creation
logic there. For example, if you use `WTForms-Alchemy <https://github.com/kvesteri/wtforms-alchemy>`_, all you have to do
is to put appropriate form generation code into your `ModelView` class into the
`scaffold_form` method.
SQLAlchemy SQLAlchemy
---------- ----------
1. If `synonym_property` does not return SQLAlchemy field, Flask-Admin 1. If `synonym_property` does not return SQLAlchemy field, Flask-Admin
won't be able to figure out what to do with it and won't generate form won't be able to figure out what to do with it and won't generate form
field. In this case, you need to manually contribute field:: field. In this case, you need to manually contribute field::
class MyView(ModelView): class MyView(ModelView):
def scaffold_form(self): def scaffold_form(self):
...@@ -42,4 +47,4 @@ MongoEngine ...@@ -42,4 +47,4 @@ MongoEngine
----------- -----------
1. Flask-Admin supports GridFS backed image and file uploads. Done through 1. Flask-Admin supports GridFS backed image and file uploads. Done through
WTForms fields and documentation can be found here :mod:`flask.ext.admin.contrib.mongoengine.fields`. WTForms fields and documentation can be found here :mod:`flask.ext.admin.contrib.mongoengine.fields`.
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