DEV Community

Ravi Shanker Kushwaha
Ravi Shanker Kushwaha

Posted on

πŸš€ How to Deploy a Django App on Render.com β€” Step-by-Step Guide

Deploying your Django app to Render.com is fast and easy if you follow the right steps. In this blog, I’ll walk you through setting up a production-ready Django project on Render, including database configuration, static files, and more.


🧱 1. Prepare Your Django Project

Start with a Django project that runs locally.

βœ… Install Required Packages

Make sure you have the following in requirements.txt:

gunicorn
dj-database-url
psycopg2-binary
whitenoise
Enter fullscreen mode Exit fullscreen mode

Install them if needed:

pip install gunicorn dj-database-url psycopg2-binary whitenoise
Enter fullscreen mode Exit fullscreen mode

βš™οΈ 2. Update Django Settings for Production

Edit your settings.py:

πŸ” Allowed Hosts

ALLOWED_HOSTS = ['your-app-name.onrender.com']
Enter fullscreen mode Exit fullscreen mode

🧾 Use this .env file (You can add your other variables)

You can use a library like django-environ to access your variables in settings.py.

DEBUG=0
SECRET_KEY=your-complex-secret-key
ALLOWED_HOSTS=localhost,127.0.0.1,your-app-name.onrender.com
DATABASE_URL=postgres://db_user:password@hostname:PORT/db_name
Enter fullscreen mode Exit fullscreen mode

πŸ—„οΈ Database (PostgreSQL)

Replace the default SQLite config:

import dj_database_url
import os

DATABASES = {
    'default': dj_database_url.config(
        default=os.environ.get('DATABASE_URL'),
        conn_max_age=600,
        ssl_require=True
    )
}
Enter fullscreen mode Exit fullscreen mode

Render will inject the DATABASE_URL environment variable when you connect your PostgreSQL service.

🧾 Static Files

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

MIDDLEWARE = [
    'whitenoise.middleware.WhiteNoiseMiddleware',
    # ... existing middleware
]
Enter fullscreen mode Exit fullscreen mode

πŸ“¦ 3. Add a Procfile in the Root Directory

Render uses this to know how to run your app:

web: gunicorn your_project_name.wsgi
Enter fullscreen mode Exit fullscreen mode

Replace your_project_name with your actual Django project folder name.


πŸ—ƒοΈ 4. Set Up a PostgreSQL Database on Render

  1. Go to Render dashboard β†’ Databases β†’ New PostgreSQL
  2. Copy the generated DATABASE_URL
  3. Go to your Web Service β†’ Environment β†’ Add:
    • DATABASE_URL = <paste_here>
  4. Or you can directly upload your .env file

βš™οΈ 5. Set Up Static Files and Migrations

Option A: Use render.yaml

Create a render.yaml file:

services:
  - type: web
    name: your-app-name
    env: python
    buildCommand: |
      pip install -r requirements.txt
      python manage.py collectstatic --noinput
      python manage.py migrate
    startCommand: gunicorn your_project_name.wsgi
    envVars:
      - key: DJANGO_SETTINGS_MODULE
        value: your_project_name.settings
Enter fullscreen mode Exit fullscreen mode

Push this to your GitHub repo.

Option B: Manually Run Migrations and Collectstatic

Use the Shell in Render’s dashboard:

python manage.py migrate
python manage.py collectstatic --noinput
Enter fullscreen mode Exit fullscreen mode

βœ… 6. Final Touches

  • Make sure DEBUG = False in production.
  • Use SECRET_KEY from an environment variable.
  • If you use media files (uploads), you’ll need S3 or similar.

🏁 You're Live!

After all these steps, your Django app should be live at:

https://your-app-name.onrender.com/
Enter fullscreen mode Exit fullscreen mode

If the admin panel has no styles β€” don’t worry, just ensure:

python manage.py collectstatic --noinput
Enter fullscreen mode Exit fullscreen mode

...and it’ll work like a charm πŸš€


πŸ’¬ Feel free to drop a comment if you face any issues β€” happy to help!

Google AI Education track image

Build Apps with Google AI Studio 🧱

This track will guide you through Google AI Studio's new "Build apps with Gemini" feature, where you can turn a simple text prompt into a fully functional, deployed web application in minutes.

Read more β†’

Top comments (0)

Runner H image

Automate Your Workflow in Slack, Gmail, Notion & more

Runner H connects to your favorite tools and handles repetitive tasks for you. Save hours daily. Try it free while it’s in beta.

Try for Free

πŸ‘‹ Kindness is contagious

Explore this practical breakdown on DEV’s open platform, where developers from every background come together to push boundaries. No matter your experience, your viewpoint enriches the conversation.

Dropping a simple β€œthank you” or question in the comments goes a long way in supporting authorsβ€”your feedback helps ideas evolve.

At DEV, shared discovery drives progress and builds lasting bonds. If this post resonated, a quick nod of appreciation can make all the difference.

Okay