A full-featured Blogging Platform built with Django REST Framework, PostgreSQL, and Docker, featuring JWT authentication, filters, nested comments, Celery background tasks for email notifications, and an admin dashboard with advanced filtering.
- JWT-based authentication (Access & Refresh tokens).
- Token blacklisting & rotation support.
- Secure login, registration, and logout endpoints.
- CRUD operations for posts.
- Only authors can edit or delete their posts.
- Nested comment system (reply to comments).
- Like/unlike functionality (one like per user per post).
- Full-text and partial search using Postgres SearchVector.
-
Custom
PostFilterclass usingdjango-filter. -
Filter posts by:
- Title
- Author email
- Content
- Date range
- Likes range
- Comments range
- Has comments (boolean)
-
Combined full-text search using
qparameter. -
Admin filters for title, author, date, likes, and comments.
- Uses Celery task queue and Redis as broker.
- Sends asynchronous email notifications when a user comments on a post.
- Background processing ensures non-blocking user experience.
- Custom admin filters and search for posts.
- Comment and Like management.
- Inline display of related comments & likes.
-
Complete Docker environment for local development.
-
Containers:
webโ Django + Gunicorndbโ PostgreSQLredisโ Redis server for Celeryworkerโ Celery worker
-
Easy setup using
docker-compose.
| Layer | Technology |
|---|---|
| Backend | Django, Django REST Framework |
| Database | PostgreSQL |
| Async Tasks | Celery, Redis |
| Auth | JWT (SimpleJWT) |
| Containerization | Docker, Docker Compose |
| Filtering/Search | django-filters, SearchVector (PostgreSQL) |
| Testing Tools | Postman, curl |
git clone https://github.com/saddarudin-nextgeni/django-blog-app.git
cd django-blog-appExample environment variables:
SECRET_KEY=your-secret-key
DEBUG=True
DATABASE_NAME=blogdb
DATABASE_USER=bloguser
DATABASE_PASSWORD=blogpassword
DATABASE_HOST=db
DATABASE_PORT=5432
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_HOST_USER=[email protected]
EMAIL_HOST_PASSWORD=your_password
EMAIL_USE_TLS=Truedocker-compose up --buildIt will start:
- Django API
- PostgreSQL
- Redis
- Celery Worker
docker-compose exec web python manage.py migratedocker-compose exec web python manage.py createsuperuser| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/auth/register/ |
Register new user | โ |
| POST | /api/auth/login/ |
Obtain JWT token | โ |
| POST | /api/auth/token/refresh/ |
Refresh access token | โ |
| GET | /api/posts/ |
List all posts (with filters/search) | โ /โ |
| GET | /api/posts/mine/ |
List posts by logged-in user | โ |
| POST | /api/posts/create/ |
Create new post | โ |
| GET | /api/posts/<id>/ |
Get post detail (with nested comments) | โ /โ |
| PUT/PATCH | /api/posts/<id>/edit/ |
Update post (only author) | โ |
| DELETE | /api/posts/<id>/edit/ |
Delete post (only author) | โ |
| GET/POST | /api/posts/<id>/comments/ |
List/Create comment | โ |
| PUT/PATCH/DELETE | /api/comments/<id>/edit/ |
Edit/Delete comment (only author) | โ |
GET /api/posts/?title=django
GET /api/posts/[email protected]
GET /api/posts/?date_from=2025-10-01&date_to=2025-10-15
GET /api/posts/?min_likes=5&max_likes=20
GET /api/posts/?min_comments=2
GET /api/posts/?has_comments=true
GET /api/posts/?q=how to django
When a user comments on a post, a Celery task is triggered:
@shared_task
def send_comment_notification(post_id, comment_author):
post = Post.objects.get(id=post_id)
subject = f"New comment on your post '{post.title}'"
message = f"{comment_author} commented on your post."
send_mail(subject, message, EMAIL_HOST_USER, [post.author.email])This task runs asynchronously using Redis as the message broker.
- Custom Permissions:
IsAuthorOrReadOnlyto restrict edit/delete. - Django Filters for range/date/boolean filtering.
- SearchVector + SearchRank for full-text search.
- Celery tasks for non-blocking email notifications.
- Custom Admin filters and UI enhancements.
- Dockerized environment for easy deployment.
# Run Celery Worker
docker-compose exec web celery -A core worker -l info
# Run Django Shell
docker-compose exec web python manage.py shell
# Collect static files (if needed)
docker-compose exec web python manage.py collectstaticblog_project/
โ
โโโ blog/ # Main app
โ โโโ models.py # Post, Comment, Like models
โ โโโ serializers.py # DRF serializers
โ โโโ views.py # API endpoints
โ โโโ filters.py # Custom filters
โ โโโ tasks.py # Celery tasks for email
โ โโโ admin.py # Admin filters
โ โโโ urls.py # API routes
โ
โโโ users/ # Custom user model & auth
โ โโโ models.py
โ โโโ serializers.py
โ โโโ views.py
โ
โโโ core/
โ โโโ settings.py
โ โโโ celery.py
โ โโโ urls.py
โ
โโโ Dockerfile
โโโ docker-compose.yml
โโโ requirements.txt
โโโ README.md