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
3cc76f1a
Commit
3cc76f1a
authored
Oct 20, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More docs
parent
459410a3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
6 deletions
+45
-6
index.rst
doc/api/index.rst
+1
-0
mod_contrib_mongoengine_fields.rst
doc/api/mod_contrib_mongoengine_fields.rst
+14
-0
tips.rst
doc/tips.rst
+23
-6
fields.py
flask_admin/contrib/mongoengine/fields.py
+7
-0
No files found.
doc/api/index.rst
View file @
3cc76f1a
...
...
@@ -15,6 +15,7 @@ API
mod_contrib_sqla
mod_contrib_mongoengine
mod_contrib_mongoengine_fields
mod_contrib_peewee
mod_contrib_pymongo
mod_contrib_fileadmin
...
...
doc/api/mod_contrib_mongoengine_fields.rst
0 → 100644
View file @
3cc76f1a
``flask.ext.admin.contrib.mongoengine.fields``
==============================================
.. automodule:: flask.ext.admin.contrib.mongoengine.fields
.. autoclass:: ModelFormField
:members:
.. autoclass:: MongoFileField
:members:
.. autoclass:: MongoImageField
:members:
doc/tips.rst
View file @
3cc76f1a
...
...
@@ -4,14 +4,25 @@ Usage Tips
General tips
------------
1. Use class inheritance. If your models share common functionality,
create base class which will be responsible for this functionality.
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
inherits from proper Flask-Admin view class.
For example - permissions. Don't implement `is_accessible` in every administrative view. Create your own base class,
implement is_accessible there and use it instead.
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` there and use this class for all your views.
2. You can override templates either by using `ModelView` properties or
putting customized version into your `templates/admin/` directory
2. You can override used templates either by using `ModelView` properties (such as
`list_template`, `create_template`, `edit_template`) or
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:
- Override create/edit template
- Use new :mod:`flask.ext.admin.form.rules` form rendering rules
4. Flask-Admin has that manage file/image uploads and store result in model field. You can
find documentation here - :mod:`flask.ext.admin.form.upload`.
SQLAlchemy
...
...
@@ -26,3 +37,9 @@ field. In this case, you need to manually contribute field::
form_class = super(UserView, self).scaffold_form()
form_class.extra = TextField('Extra')
return form_class
MongoEngine
-----------
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`.
flask_admin/contrib/mongoengine/fields.py
View file @
3cc76f1a
...
...
@@ -28,6 +28,9 @@ class ModelFormField(fields.FormField):
class
MongoFileField
(
fields
.
FileField
):
"""
GridFS file field.
"""
widget
=
widgets
.
MongoFileInput
()
def
__init__
(
self
,
label
=
None
,
validators
=
None
,
**
kwargs
):
...
...
@@ -63,4 +66,8 @@ class MongoFileField(fields.FileField):
class
MongoImageField
(
MongoFileField
):
"""
GridFS image field.
"""
widget
=
widgets
.
MongoImageInput
()
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