The easiest way I found this with the Mongoengine model was as follows:
import mongoengine from models import MyModel connection = mongoengine.connection.get_connection() db = connection[MyModel._get_db().name] stats = db.command("collstats", MyModel._get_collection_name())
This should allow transparent changes to the collection and database using the mongoengine configuration settings.
source share