Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
f51b56ab
Commit
f51b56ab
authored
Oct 20, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doc fixes. Fixed #267
parent
ee966c12
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
17 deletions
+22
-17
tips.rst
doc/tips.rst
+22
-17
No files found.
doc/tips.rst
View file @
f51b56ab
...
@@ -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`.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment