Issue
We are planning to develop an app using Flask and Mongoengine. However, we already have some mongoengine document definitions used in a non flask app, and if possible we would like to refactor those definitions into one package, in order to use it from bothe the flask and the non flask application.
Is this possible? I've read the init code for Flask Mongoengine, and it seems it just overrides some base classes for documents, and pulls the config from the flask app. Also, ive found this (unanswered) question:
Pulling basic mongoengine document definitions into flask-mongoengine
Solution
You don't even need Flask-Mongoengine. I'm currently working on Flask app with Mongoengine but I don't even use Flask-Mongoengine. I feel more comfortable using vanilla mongoengine. Just make sure you connect to your existing MongoDB somewhere.
mongoengine.connect(MONGODB_DB, host=MONGODB_HOST, port=MONGODB_PORT)
Answered By - Joseph Vargas
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.