AWS RDS Creation and Integration with Django
Last Updated :
03 Nov, 2025
Integrating a Django application with Amazon Web Services (AWS) Relational Database Service (RDS) allows seamless interaction with a managed PostgreSQL database. AWS RDS handles database management tasks such as backups, scaling, and security, enabling developers to focus on building application features.
PostgreSQL is chosen as the database engine because it is Django’s recommended option, making it ideal for development and small-scale deployments.
- Offers a robust, scalable, and reliable backend for Django applications.
- Reduces the need to manually manage database infrastructure.
Step 1: Create an AWS RDS Instance
Sign in to the AWS Management Console and access "RDS" via the search bar:
AWS Search FieldAfter the service starts, the screen displays as follows:
Aurora and RDS DashboardIn RDS, create a database by going to the Database section or clicking Create database. During creation, select the type and settings for the database. To add a PostgreSQL database to the Django project, choose the following options:
Use the Standard Create method:
Create DatabaseSelect PostgreSQL as the database engine:
Engine MethodsChoose the Free Tier template:
Templates, Availability and durabilitySet Database Name, Username, and Password
Use any values for each field:
SettingsKeep the default instance configuration and disable Storage Autoscaling:
Enabling autoscaling it is optional and not required for testing:
Instance configuration and storageEnable Public Access and create a new security group:
ConnectivityKeep the default database authentication settings:
Database authenticationKeep the default monitoring:
MonitoringCreate database:
Estimated monthly costsThe process may take a few minutes; once finished, a new PostgreSQL database will be ready for use with Django.
Retrieve RDS Host and Port
The HOST and PORT are listed under the Connectivity & security section of the RDS instance, labeled as Endpoint and Port:
Step 2: Install Required Packages in Django Project
Install the PostgreSQL adapter:
pip install psycopg2-binary
psycopg2-binary is a precompiled PostgreSQL adapter for Python.
import os
from django.core.exceptions import ImproperlyConfigured
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('DB_NAME'),
'USER': os.environ.get('DB_USER'),
'PASSWORD': os.environ.get('DB_PASSWORD'),
'HOST': os.environ.get('DB_HOST'),
'PORT': os.environ.get('DB_PORT', '5432')
}
}
Example .env:
DB_NAME=mydjango
DB_USER=postgres
DB_PASSWORD=MySecurePass123!
DB_HOST=my-django-db.xxxxx.us-east-1.rds.amazonaws.com
DB_PORT=5432
Step 4: Run Migrations and Test the Connection
python manage.py makemigrations
python manage.py migrate
Create a superuser:
python manage.py createsuperuser
Run the server:
python manage.py runserver.
Visit: http://127.0.0.1:8000/admin/ and log in, the data is now stored in RDS.
Explore
Python Fundamentals
Python Data Structures
Advanced Python
Data Science with Python
Web Development with Python
Python Practice