Deploying to Render
Learn about Deploying to Render
What is Render?
Render is a modern cloud platform that makes deploying web applications simple. It supports Python, Node.js, Docker, and many other runtimes. Render provides free tiers for web services and databases, making it an excellent choice for deploying Django applications without upfront costs.
Preparing the Project for Deployment
Install gunicorn, a production-grade WSGI server for Python:
pip install gunicorn
pip freeze > requirements.txt
Create a render.yaml file or configure the build and start commands directly in the Render dashboard.
Setting Up a PostgreSQL Database
In the Render dashboard, create a new PostgreSQL database. Render provides a free tier with 1GB of storage. Copy the Internal Database URL that Render provides. Install the required packages:
pip install dj-database-url psycopg2-binary
Configuring Environment Variables
In your Render web service settings, add environment variables for SECRET_KEY, DATABASE_URL, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and any other sensitive configuration. Update your settings.py to read these values from the environment using os.environ.get() instead of hardcoding them.
Connecting to GitHub
Push your complete project to a GitHub repository. In the Render dashboard, click "New Web Service" and connect your GitHub account. Select the repository containing your Django project. Render will detect the Python runtime and suggest default build settings.
Going Live
Click "Create Web Service". Render will pull your code from GitHub, install the dependencies from requirements.txt, run collectstatic, and start gunicorn. After a few minutes, your application will be live at a URL like https://your-app.onrender.com. Run the Django migrate command through Render's shell to set up the database tables. Test every feature — creating contacts, searching, uploading photos, and verifying that the S3 images display correctly.