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 render.com. Here is the reason for my decision which is it’s FREE. Yes It’s completely free to deploy application in the render.com but it can be scale when it’s needed. Here is the things I do to deploy my Django application in render.com
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
DEBUG=True SECRET_KEY=whateveryoursecretkey DATABASE_URL=
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 ./build.sh file to run the collect static and migrate on build.