This content originally appeared on DEV Community and was authored by Ebenezer Lamptey
Creating my first full Django backend project from scratch was both exciting and eye-opening. I built a To-Do List API, added PostgreSQL, containerized the entire application with Docker.
This blog post documents that journey; lessons learned, hurdles faced, and how I overcame them. If you’re a beginner backend developer or looking to dip your feet into Docker and Django, I hope this post inspires and helps you!
Project Goal: Build a Simple Yet Scalable To-Do List API
The idea was to build a lightweight RESTful To-Do List API using Django and Django REST Framework (DRF). Features included:
- User registration and login with access/refresh tokens
- Secure authentication with JWT
- Users can only access and manage their own tasks
- CRUD operations on tasks
- Mark tasks as completed (Boolean toggle)
- Search, filter, and order support
- Switched from SQLite to PostgreSQL
- Docker support for consistent setup
Note: Deployment is a planned next step. This project has not yet been deployed.
Step-by-Step Journey
Building the API with Django + DRF
I started with Django and Django REST Framework, setting up views, serializers, and models to handle ToDo objects on a per-user basis. Also worked on urls. register it in admin.py; an in-built admin page for Django.
Integrating JWT Authentication
Using SimpleJWT, I added token-based authentication, allowing users to securely interact with their own tasks.Swapping SQLite for PostgreSQL
SQLite was fine initially, but PostgreSQL better reflects real-world apps, especially when containerizing. Before i did that i had to save keys and important information in an env file to avoid commit keys and secrets to the repository. This is for security purposes.
- Containerizing with Docker I wrote a Dockerfile, .dockerignore, and docker-compose.yml to package both the Django app and PostgreSQL database.
Key learnings:
- Why we don’t use virtual environments in containers
- Setting up environment variables properly
- Troubleshooting docker-compose issues
- Testing Locally Using:
docker-compose up --build
I run into an issue where the database wasn’t migrated. so I had to run the following commands to make the API work.
docker exec -it django-docker python /TDL/manage.py migrate
docker exec -it django-docker python /TDL/manage.py createsuperuser
createsuperuser was for admin access.
I tested the API endpoints through the container and ensured they worked with the PostgreSQL service.
What’s Next?
I explored deployment on Render using a Docker-based service. Though I didn’t complete deployment (since free tier ends soon), I now understand what it takes to deploy to production.
Planning to finalize and deploy this soon.
Reflection
This journey wasn’t just about building an API. It was about preparing to scale, containerize, and potentially deploy. I hit some roadblocks with .env handling, database permissions, and YAML formatting, but those were key moments in learning real backend + DevOps skills.
You can access the entire project in my Github:
https://github.com/nlankwei5/To-Do-List-Api
Feel free to comment, like and share. Also give advice on how to make this better.
This content originally appeared on DEV Community and was authored by Ebenezer Lamptey