Skip to content

Commit 9ba4283

Browse files
committed
Added More Setup Information To The Documentation
Added information about the init_app() method in the docs to make it clear that this library is compatible with flask application factories. I almost did not use this project because I thought that this method was not supported.
1 parent 4f7c4c8 commit 9ba4283

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ Basic setup is easy, just fetch the extension::
2626
app.config.from_pyfile('the-config.cfg')
2727
db = MongoEngine(app)
2828

29+
Or, if you are setting up your database before your app is initialized, as is the case with application factories::
2930

31+
from flask import Flask
32+
from flask.ext.mongoengine import MongoEngine
33+
db = MongoEngine()
34+
...
35+
app = Flask(__name__)
36+
app.config.from_pyfile('the-config.cfg')
37+
db.init_app(app)
38+
3039
To configure the MongoDB connection settings set a key (DB, USERNAME, PASSWORD, HOST, PORT) in the
3140
`'MONGODB_SETTINGS'` dictionary wih `app.config`. For example :
3241

0 commit comments

Comments
 (0)