Base module API
This is the flask_mongoengine main modules API documentation.
flask_mongoengine.connection module
Module responsible for connection setup.
Return known pymongo setting name, or lower case name for unknown. This problem was discovered in issue #451. As mentioned there, pymongo settings are not case-sensitive, but mongoengine uses the exact name of some settings for matching, overwriting pymongo behaviour.
Remove MONGODB_ prefix from dict values, to correct bypass to mongoengine.
Given Flask application's config dict, extract relevant config vars out of it and establish MongoEngine connection(s) based on them.
Given Flask application's config dict, extract and return connection settings.
flask_mongoengine.db_fields module
Responsible for mongoengine fields extension, if WTForms integration is used.
Extension wrapper class for mongoengine BaseField. This enables flask-mongoengine wtf to extend the number of field parameters, and settings on behalf of document model form generator for WTForm.
Class variables:
DEFAULT_WTF_CHOICES_FIELD— Default WTForms Field used for db fields whenchoicesoption specified.DEFAULT_WTF_FIELD— Default WTForms Field used for db field.
Extends mongoengine.fields.BinaryField with wtf required parameters. All arguments should be passed as keyword arguments.
Protection from execution of to_wtf_field() in form generation.
Raises: NotImplementedError – Field converter to WTForm Field not implemented.
Extends mongoengine.fields.BooleanField with wtf required parameters. All arguments should be passed as keyword arguments.
Extends mongoengine.fields.CachedReferenceField with wtf required parameters. All arguments should be passed as keyword arguments.
Raises: NotImplementedError – Field converter to WTForm Field not implemented.
Extends mongoengine.fields.ComplexDateTimeField with wtf required parameters. During WTForm generation this field uses wtforms.fields.DateTimeLocalField with milliseconds accuracy.
Extends mongoengine.fields.DateField with wtf required parameters. All arguments should be passed as keyword arguments.
Extends mongoengine.fields.DateTimeField with wtf required parameters. All arguments should be passed as keyword arguments.
Extends mongoengine.fields.DecimalField with wtf required parameters. Extends form validators with wtforms.validators.NumberRange.
Extends mongoengine.fields.DictField with wtf required parameters. Extends default field options with null bypass.
Extends mongoengine.fields.EmailField with wtf required parameters. Extends form validators with wtforms.validators.Email.
Changed in version 2.0.0: Default form field output changed from NoneStringField to MongoEmailField.
Extends mongoengine.fields.EmbeddedDocumentField with wtf required parameters.
Extends mongoengine.fields.EmbeddedDocumentListField with wtf required parameters.
Extends mongoengine.fields.EnumField with wtf required parameters.
Extends mongoengine.fields.FileField with wtf required parameters.
Extends mongoengine.fields.FloatField with wtf required parameters. Extends form validators with wtforms.validators.NumberRange.
Changed in version 2.0.0: Default form field output changed from wtforms.fields.FloatField to MongoFloatField with 'numbers' input type.
Extends mongoengine.fields.IntField with wtf required parameters. Extends form validators with wtforms.validators.NumberRange.
Extends mongoengine.fields.ListField with wtf required parameters.
Extends mongoengine.fields.ReferenceField with wtf required parameters.
Extends mongoengine.fields.SortedListField with wtf required parameters.
Extends mongoengine.fields.StringField with wtf required parameters. By default uses MongoTextAreaField for fields without size, and MongoStringField with Length validator when size is set.
Extends mongoengine.fields.URLField with wtf required parameters.
flask_mongoengine.decorators module
Decorator that raises RuntimeError if WTForms is not installed, when decorated method is called.
flask_mongoengine.documents module
Extends mongoengine.queryset.QuerySet class with handy methods.
Get a document and raise a 404 Not Found error if it doesn't exist.
Same as get_or_404, but uses first() not get().
Paginate the QuerySet with a certain number of docs per page and return docs for a given page.
Paginate items within a list field from one document in the QuerySet.
flask_mongoengine.json module
Convert objects related to Mongo database to JSON.
Extend Flask JSON Encoder 'default' method with support of Mongo objects.
Override the Flask application's default JSON encoder with one that supports Mongo objects.
flask_mongoengine.pagination module
Internal helper class returned by BaseQuerySet.paginate(). Provides navigation helpers for paginated results.
Iterate over page numbers in pagination range.
Return a Pagination object for the next page.
Return a Pagination object for the previous page.
Pagination for a list field within a single document. Returned by BaseQuerySet.paginate_field().
flask_mongoengine.panels module
Panel that displays MongoDB queries executed during a request. Add to DEBUG_TB_PANELS in your Flask config to enable.
A pymongo CommandListener instance. Register with pymongo.monitoring.register() before establishing the database connection.
flask_mongoengine.sessions module
A session interface that uses MongoEngine as the backend. Assign to app.session_interface to enable.
Module contents
Main class used for initialization of Flask-MongoEngine.
Initialize the extension. If app is provided, calls init_app(app) immediately.
Initialize the extension for the given Flask app. Sets up database connection and registers JSON encoder override.
Return MongoDB connection(s) associated with this MongoEngine instance.
Return a MongoEngine instance associated with current Flask app.