July 2019
Beginner to intermediate
302 pages
9h 38m
English
First, manually create a database in MongoDB using the command line. Let's name this database my_catalog:
>>> mongoMongoDB shell version: v4.0.4> use my_catalogswitched to db my_catalog
The following is an application that is a rewrite of our catalog application using MongoDB.
The first change comes to our configuration file, my_app/__init__.py:
from flask import Flask
from flask_mongoengine import MongoEngine
from redis import Redis
app = Flask(__name__)
app.config['MONGODB_SETTINGS'] = {'DB': 'my_catalog'}
app.debug = True
db = MongoEngine(app)
redis = Redis()
from my_app.catalog.views import catalog
app.register_blueprint(catalog)