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

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
- Set up a MongoDB instance (self-hosted on a VM or MongoDB Atlas).
- Point Django's database settings at it via the connector.
- 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.