How to Deploy Django for Free

Published 30 Nov, 2021

Reading time: 2 Mins

There is lot of ways to deploy Django application but one of the cheapest way to deploy application is using

Few days back I wrote this application, it’s called BlogStreak. I usually deploy my application in the virtual private server but this time I picked Here is the reason for my decision which is it’s FREE. Yes It’s completely free to deploy application in the but it can be scale when it’s needed. Here is the things I do to deploy my Django application in

Environment variable

First I advice you to get rid of the hard coded variable and always stick with environment variable. This is the best option to protect your code secrets. I always create the .env file in my root project. And I will add whatever my secrets in there.

Here is my sample .env file


Note: I have used django-environ for getting the environment variables from the .env file. Which is great for Django application. Render also provides free database Postgresql service. So first you have to create the database instance and add this into DATABASE_URL when you’re ready to deploy the application.

Serve static files

Render is not a vps so you can have the stable hard drive so we will use whitenoiseto serve the static files. Refer this Using WhiteNoise with Django — WhiteNoise 5.3.0 documentation for how to install and configure for the Django application. And finally you can deploy the application using the render deploy procedure. There is nothing you need to configure in the settings. Oh also you need to have gunicorn installed and create the ./ file to run the collect static and migrate on build.

This article published under development on django tags. If you wish to receive email from me when I post a new blog post then please subscribe to my newsletter.

You might also like