Skip to content

Connect parameter #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
2 commits merged into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ Connection settings may also be provided individually by prefixing the setting w
app.config['MONGODB_USERNAME'] = 'webapp'
app.config['MONGODB_PASSWORD'] = 'pwd123'

By default flask-mongoengine open the connection when extension is instanciated but you can configure it
to open connection only on first database access by setting the ``MONGODB_SETTINGS['connect']`` parameter
or its ``MONGODB_CONNECT`` flat equivalent to ``False``::

app.config['MONGODB_SETTINGS'] = {
'host': 'mongodb://localhost/database_name',
'connect': False,
}
# or
app.config['MONGODB_CONNECT'] = False

Custom Queryset
===============
Expand Down
2 changes: 1 addition & 1 deletion flask_mongoengine/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


MONGODB_CONF_VARS = ('MONGODB_ALIAS', 'MONGODB_DB', 'MONGODB_HOST', 'MONGODB_IS_MOCK',
'MONGODB_PASSWORD', 'MONGODB_PORT', 'MONGODB_USERNAME')
'MONGODB_PASSWORD', 'MONGODB_PORT', 'MONGODB_USERNAME', 'MONGODB_CONNECT')


class InvalidSettingsError(Exception):
Expand Down