This is a Django application that demonstrates a user management system with several key features:
- Creates and lists users
- Supports avatar image uploads
- Uses MySQL for the database
- Uses Redis for caching
- Runs in Docker containers
- Python with Django 5.2
- MySQL 8.0
- Redis 7
- Docker + Docker Compose
- Django templates
core/models.py- Defines the UserProfile modelcore/forms.py- Contains UserCreationForm for adding userscore/views.py- Includes view functions for user managementcore/urls.py- Defines URL routing for the appdocker-compose.yml- Configures three services: web, MySQL, and RedisDockerfile- Builds the Django app container
The application has a custom user management system that extends Django's built-in User model with a UserProfile model that includes:
- Avatar images (stored in media/avatars/)
- User status tracking
The application uses Redis for caching user data:
- The
user_managementview incore/views.pyfirst checks the Redis cache - If data isn't cached, it pulls from the database and caches it
- The cache is invalidated when new users are added
The application uses MySQL:
- The app uses MySQL, configured via environment variables (MYSQL_*)
- Migrations are automatically applied at container startup
To run the app locally:
docker-compose up --buildDocker Compose sets up three services:
- The web app (Django)
- MySQL
- Redis
The web application will be available at http://localhost:8000/
- The application uses Django's built-in User model with a custom UserProfile model
- Avatar images are stored in a persistent volume mounted at
/app/media - Database and Redis data are also stored in persistent volumes
This app is also set up for easy deployment on Hostim.dev. It shows how to spin up a full stack app with a database and cache inside containers. For detailed steps on hosting this on Hostim.dev, check out the Hostim.dev deployment guide.