So you’ve decided to use Django for your next side project. That’s a great choice! Django is a fully-featured web framework that comes with a lot of things already set up for you. This means that you can develop and iterate quickly and get your project pushed out to your users. Some of the largest websites and organizations in the world: The Washington Post, NASA, Pinterest, and many more, use Django as their web framework. You get versioning, a browserable API, and the ability to push regular releases. If that all sounds good, the next thing you need to figure out is: where the heck should you host your application? Today we’re going to take a look at the best places to host a Django web application. Specifically we’ll focus on people who are just starting out. If you have an established website that you are looking to move onto the Django framework, that is out of scope for the purposes of this post.
Today, we’ll look at the best hosting providers to get started with a Django application and framework. Depending on how much flexibility you want versus ease of use, one of the three providers below should suit your needs perfectly.
Provider 1: DigitalOcean
DigitalOcean is a well-known provider of Linux-based hosting. As of 2018 they were the third-largest hosting company in the world, so you know that they are a well established service. They were one of the first cloud-hosting companies to offer SSD-based virtual machines. While setting up the environment and server will be more involved than the other choices on this list, they are still a fairly easy platform to deploy and manage on. DigitalOcean also scales fairly well, and prices start at a very reasonable $5/month for 1GB of memory, 1vCPU, 25 GB of disk, and 1TB of transfer. For a starting application that is more than enough. Because the cloud server is an SSD, the speed is also quick, which is important, especially if you are serving mobile users with your web application.
Because DigitalOcean provides a standard hosting service (think something like Linode), there is a high amount of flexibility and customization that you can do for your server. On the other hand it means you have to set up everything yourself. Thankfully, DigitalOcean provides you a great amount of detailed tutorials for set up–including how to set up django on a debian 9 server. They also include tutorials for various versions of Ubuntu, and you can even request tutorials if you’d like to use some other method of deployment such as Docker. You can see by the length of the tutorials that the setup will be somewhat involved, but the detail that the tutorial goes into means that you shouldn’t have any issues.
If you’re already comfortable setting up a VPS going with DigitalOcean is probably your best bet. The main downside is that you have to manage everything on your own, which can be time-consuming, especially for people who are setting things up for the first tim
e. The other services on this list are more straightforward to set up and manage a lot of other things for you, at the cost of being less flexible.
Provider 2: Heroku
Heroku is a PaaS service that was originally built for Ruby projects, but spread to support multiple different projects and frameworks. One of the great advantages of Heroku is how simple it is to deploy a project–it’s as simple as a one line git push command. They also have several other ways of deploying applications as well. Heroku also comes with a free tier of usage to start, so if you’re on a really tight budget, you can get an application up with no cost. Do note, however, that the free tier is limited in terms of compute hours and your app will go to sleep to conserve these hours if it isn’t active after a set period of time. If you’re just starting to build your app this shouldn’t be a problem. They also provide a Heroku-based subdomain for your application so you don’t even need to buy a website to get started serving your application to customers. It’s also easy to scale up the compute power you need by scaling the number of instances you need.
Heroku used to be unable to support websockets, however this has changed and they have several tutorials on how to integrate websockets for different programming languages. The main downside of Heroku is that if you need to add functionality, you can do so via various add-ons that Heroku provides, but they can add up in price very quickly. Moreover, as your app scales, Heroku can be more expensive compared to other options such as DigitalOcean and Amazon. Since Heroku itself is running EC2 instances, shifting over once you scale means you’ll get better prices but less of the deploy and management aspects of the application handled for you. However, it’s something to consider if you feel that Heroku becomes too expensive when scaling up.
If you’re looking for something that requires less set up than DigitalOcean, Heroku is a good choice. There is still some set up but it is much easier to manage compared a service like DigitalOcean where you have to do all of the server set up by yourself.
Provider 3: PythonAnywhere
PythonAnywhere is another service that allows you to deploy Django web apps. In general they support webapps written in any WSGI framework such as Flask. PythonAnywhere starts as a fully configured Python environment, with most of the system packages updated to the latest versions and tested to work together. It behaves more like a server, with local storage to edit files, read logs, etc. In some sense you can think of it as a standard server provided by a VPS with a python environment already set up for you. PythonAnywhere has a free plan like Heroku, which gives you a single worker for you webapp. This is the equivalent of Heroku’s dynos, where you are given a free dyno for your Heroku application. It is very easy to set up an application because the environment is already set up for you beforehand.
Note that PythonAnywhere does not support NoSQL databases nor does it support websockets. Django itself does not officially support NoSQL databases, but there are side projects and forks that allow NoSQL functionality if you need. Django supports websockets via Channels, however PythonAnywhere does not. That’s something to keep in mind while choosing a provider. If you need NoSQL or websocket functionality, you’ll need to do extra work to integrate with your webapp if you’re using a PythonAnywhere hosted instance. They also don’t offer register services so you’ll need another service to manage the DNS, unlike Heroku, which provides a simple method to set up your nameservers.
If you’re looking to get an app up and running as quickly as possible, PythonAnywhere is quite good. Just be aware that it doesn’t support some of the functionality that the other providers offer for you.
Conclusion: Best Django Hosting
If you’re looking for hosting for your Django web application, the three hosting providers above should be a good start. Depending on whether you need more flexibility, or you’re looking to push your application live as quickly as possible, one of the providers above will get you what you need. Just note that as you start scale, it starts to make more sense to move off of the services and start handling the server set up yourself as the savings can be significant.