A beginner-friendly Django backend API for managing events and attendee registrations. This project was built for CodeAlpha Backend Development Task 2.
- Python
- Django
- Django REST Framework
- SQLite
- pytest
- pytest-django
- Django Admin
Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activateInstall dependencies:
python -m pip install -r requirements.txtApply database migrations:
python manage.py migratepython manage.py runserverThe API will be available at:
http://127.0.0.1:8000/
http://127.0.0.1:8000/api/
pytest| Method | Endpoint | Description |
|---|---|---|
| GET | / |
API overview with project links |
| GET | /api/health/ |
Check that the API is running |
| GET | /api/events/ |
List events |
| GET | /api/events/<id>/ |
Get event details |
| POST | /api/registrations/ |
Public registration for an event |
| GET | /api/registrations/ |
List registrations (staff/admin only) |
| GET | /api/registrations/<id>/ |
Get registration details (staff/admin only) |
| DELETE | /api/registrations/<id>/ |
Cancel a registration (staff/admin only) |
full_name,email, andeventare required.- The event must exist.
- Event
end_timemust be afterstart_time. - The same email cannot have more than one active registration for the same event.
- Registration is blocked when the event capacity is full.
- Deleting a registration changes its status to
cancelled; it does not remove the row from the database. - Registration creation is public. Listing, viewing, and cancelling registrations require a staff/admin user.
API overview:
curl http://127.0.0.1:8000/Health check:
curl http://127.0.0.1:8000/api/health/List events:
curl http://127.0.0.1:8000/api/events/Get one event:
curl http://127.0.0.1:8000/api/events/1/Create a registration:
curl -X POST http://127.0.0.1:8000/api/registrations/ \
-H "Content-Type: application/json" \
-d '{"event": 1, "full_name": "Mona Ali", "email": "mona@example.com"}'List registrations (requires staff/admin authentication):
curl http://127.0.0.1:8000/api/registrations/Get one registration (requires staff/admin authentication):
curl http://127.0.0.1:8000/api/registrations/1/Cancel a registration (requires staff/admin authentication):
curl -X DELETE http://127.0.0.1:8000/api/registrations/1/The project includes a Django Admin panel so event organizers can manage the system without a custom frontend.
Create an admin user:
python manage.py createsuperuserStart the development server:
python manage.py runserverOpen the admin panel:
http://127.0.0.1:8000/admin/
Organizers can use the admin panel to:
- Create and edit events.
- View attendee registrations.
- Search and filter events and registrations.
- Cancel selected registrations using the admin action.
Admin validation also shows friendly errors for duplicate active registrations and full events.