Introduction
Deploying Django has often been a confusing and hard topic for many who are starting out in Django development.
It takes time in playing around with various deployment options to actually get to the right technology or practices in deploying Django projects.
I will be covering the various ways to deploy your Django web application, I hope it might be useful for anyone who is starting out.
Common Questions to Deploy
Literally, it comes down to three questions you should ask yourself whenever you are looking to deploy a Django project.
- What is the cost to deploy?
- Do you require it to scale?
- How long do you plan to maintain it?
Do note that for the sake of convenience and you are the only person. Who is responsible for deploying your Django project.
Just go for cloud providers like Heroku, Linode or DigitalOcean as it will be an overkill to do it.
What is the cost to deploy?
By paying for the convenience through the use of cloud providers like Heroku, Linode, DigitalOcean or Python Anywhere.
Do note that if you plan to drive down the cost to deploy significantly, you need to understand the various technologies associated with making the process easier.
This does include the cost for maintenance of the deployment process and monitoring the health of your server.
To prevent it from crashing if your server has been overloaded through multiple requests or DDoS attacks.
Do You Require It to Scale?
You need to estimate what is the number of monthly users for your architecture when you are planning to deploy for your Django application.
There is a massive difference between scaling for ten thousands or hundred thousands of monthly users vs scaling it for one million monthly users.
The amount of scale and architecture changes required dramatically leads to the realms of Developer Operations (DevOps) or Site Reliability Engineer (SRE).
Which uses many tools & practices, this even takes from the playbook of IT service management to maintain the availability and performance of your Django project.
Which I'm pretty sure is not taught often as part of software development.
To have a glimpse of how to scale Django, I would suggest looking at the book called High-Performance Django.
This was heavily recommended by PyDanny the author for Two Scoops of Django.
That I had used it as part of a reference guide when I was starting out to learn to develop in Django.
How Long Do You Plan To Maintain It?
It is not easy to maintain a deployment infrastructure for Django by just following DevOps practices or adopting technology like Zappa or Docker.
It could take weeks or months of your time to refine and running smoothly. If you are interested in the experience in deploying Django in the production environment.
I came across Randall Degges in his article Deploying Django to deploy for a startup I am currently in.
Which was way before we pick up CI/CD practices and the use of Docker containers to make deployment and development much easier for us.
Conclusion
I hope that this article is helpful for anyone who is developing in Django and looking towards the deployment.
If you are just the only person, who is deploying the Django project you can take a look at using cloud providers or use Zappa that taps on the AWS Lambda and API Gateway for deploying your Django project using AWS.
Lastly, Before deploying your Django web application or REST API endpoints to your production environment look at Deployment Checklist and Security In Django before deploying to prevent security breaches.
If you like my article, please sign up for Max Adventurer's Newsletter for awesome content I stumble across weekly in Python, Startup and Web Development.
You can also follow me to get the latest update of my article on Dev
This post was originally posted on Max's blog at Path Towards Deploying Django - Reading Time: 3 Mins and Photo by Caleb Jones on Unsplash
Top comments (2)
Great article, Max. I'm fairly new in Django Development and is currently deploying my first Django Site to production using Heroku. However, I'm having troubles loading the images (which is uploaded from the admin) on the site. I followed the this and this from heroku's site but it returns a 500 error.
Does Zappa handle static files better than Heroku?
From what I know for Zappa makes it easy for you to deploy your Django projects on AWS very easily.
If it's related to handling static files based upon their documentation they recommend multiple combinations of using amazon specific service which you might need to explore by yourself on it.