H4 Tech Solutions Logo
All articles

Setting Up and Deploying a Django Web Application with MongoDB on GCP

Learn how to set up and deploy Django apps with MongoDB on Google Cloud Platform.

Jan 20, 2020 · 1 min read · Som

Setting Up and Deploying a Django Web Application with MongoDB on GCP

Django defaults to a relational ORM, but sometimes a document store fits the data better. This guide connects Django to MongoDB and deploys the result on Google Cloud Platform.

Connecting Django to MongoDB

The usual bridge is Djongo (or MongoEngine), which lets Django models map to MongoDB collections with minimal changes to your existing code.

Deployment outline

  1. Set up a MongoDB instance (self-hosted on a VM or MongoDB Atlas).
  2. Point Django's database settings at it via the connector.
  3. Deploy the Django app on a GCP Compute Engine VM behind Nginx.

Takeaway

Choose the datastore for the shape of your data. Django is flexible enough to sit on top of MongoDB when documents beat rows — and GCP makes hosting both straightforward.

Subscribe

Get new articles, white papers, and repos from H4Tech in your inbox.

Follow along via Subscribe via RSS