Building Python Web Apps with MongoDB

PublishedMay 30, 2018
Host(s)Michael Kennedy

In this three-part webcast series, we discuss why MongoDB is a good choice for Python web apps. We walk through building a clone of Python's packaging website ( and carefully consider the way it would be modeled in a document database like MongoDB. Finally, we build a web frontend application and deploy the web app and MongoDB to the cloud. We also discuss special considerations of running MongoDB in production.

Part 1: Introducing MongoDB for the Python Developer

In this first webcast of the series, we dive into what makes MongoDB an excellent choice for Python developers. You will see that MongoDB is a high performance, scalable database that matches Python's idioms and data structures very nicely. We'll discuss why modeling data in MongoDB (and document databases more generally) supports easily maintainable applications as well as adding a healthy dose of performance.

Concepts covered in this session include:

  • What a document database is
  • How document DBs improve modeling of application data
  • What rules and guidelines there are to help with data modeling
  • How this maps to Python-based applications
  • How to leverage MongoDB's query model

Part 2: Data access layer for Python's Packaging service PyPI

The first webcast set the stage and introduced our data model. Now it's time to write some code and make those lessons concrete. In this part, we will see that there are two basic philosophies when accessing data from Python, directly via dictionaries or at a higher level using an Object-Document Mapper (aka ODM). We'll use the ODM mongoengine to implement the entire process for viewing PyPI data and the main package details page.

Concepts covered in this session include:

  • How to connect to MongoDB
  • The tradeoff between raw connections and an ODM
  • All the CRUD operations needed to implement a rich web page
  • The key techniques for making our site perform very quickly

Part 3: Web frontend and deploying Python's Packaging service PyPI

Now that we have created the data access layer of our application, it's time to put things into production. We will focus on two core concepts in this final webcast of the series. First, we will add a web frontend / UI to our application. This will make it a real web app. Second, we will deploy that web app and our MongoDB database safely to the cloud.

Concepts covered in this session include:

  • How to use this data access layer in a Flask application
  • What is involved in using MongoDB as a web app's backend database
  • How to deploy a Python web application
  • How to start operating MongoDB in production
  • Security considerations of running MongoDB in production

About the presenter

Michael Kennedy is an author, instructor, and speaker. He is the host of the Talk Python To Me podcast and founder of Talk Python Training, an online training company for Python developers. Michael has taught over 100 week-long training courses to professional software development teams throughout the world and is an expert in Python, MongoDB, and .NET among other technologies.

Talk Python to Me podcast →

Talk Python to Me Training →

View Presentation

view presentation