A modern Django web application built with Docker, PostgreSQL, and Poetry for dependency management.
- Django 5.2+ - Latest Django framework
- PostgreSQL - Robust database backend
- Docker & Docker Compose - Containerized development environment
- Poetry - Modern Python dependency management
- Environment-based configuration - Secure configuration management
- Russian localization - Configured for Russian language and timezone
Before you begin, ensure you have the following installed:
-
Clone the repository
git clone <repository-url> cd django-example
-
Set up environment variables
cp .env.example .env # Edit .env file with your configuration -
Start the services
# Start database and storage services make storages # Start the full application make app
-
Run database migrations
make migrate
-
Create a superuser (optional)
make superuser
-
Collect static files
make collectstatic
-
Install dependencies
poetry install
-
Activate virtual environment
poetry shell
-
Set up environment variables
cp .env.example .env # Edit .env file with your configuration -
Run migrations
python manage.py migrate
-
Start development server
python manage.py runserver
The project includes a comprehensive Makefile for easy Docker management:
make storages # Start PostgreSQL database
make storages-down # Stop database services
make storages-logs # View database logs
make postgres # Connect to PostgreSQL shellmake app # Start full application stack
make app-down # Stop application stack
make app-logs # View application logsmake migrate # Run database migrations
make migrations # Create new migrations
make superuser # Create Django superuser
make collectstatic # Collect static filesdjango-example/
βββ core/ # Main Django project
β βββ apps/ # Django applications
β β βββ products/ # Products app
β βββ project/ # Project configuration
β βββ settings/ # Settings modules
β β βββ main.py # Main settings
β β βββ local.py # Local development settings
β βββ urls.py # URL configuration
β βββ wsgi.py # WSGI configuration
β βββ asgi.py # ASGI configuration
βββ docker_compose/ # Docker Compose configurations
β βββ app.yaml # Application services
β βββ storages.yaml # Database services
βββ static/ # Static files
βββ Dockerfile # Docker image configuration
βββ entrypoint.sh # Container entrypoint script
βββ Makefile # Development commands
βββ manage.py # Django management script
βββ pyproject.toml # Poetry configuration
βββ .env # Environment variables
The application uses environment variables for configuration. Key variables include:
DJANGO_KEY- Django secret keyPOSTGRES_DB- Database namePOSTGRES_USER- Database userPOSTGRES_PASSWORD- Database passwordPOSTGRES_HOST- Database hostPOSTGRES_PORT- Database portDJANGO_PORT- Django application port
The project uses a modular settings structure:
main.py- Base settings for all environmentslocal.py- Local development overrides
The project uses PostgreSQL as the primary database. The database configuration is handled through environment variables and supports:
- Connection pooling
- Environment-specific configurations
- Docker-based development setup
The application is configured for Russian localization:
- Language: Russian (
ru) - Timezone: Europe/Moscow
- Internationalization enabled
-
Security
- Change the default secret key
- Set
DEBUG = False - Configure proper
ALLOWED_HOSTS - Use environment-specific database credentials
-
Static Files
- Run
make collectstaticto collect static files - Configure static file serving for production
- Run
-
Database
- Use production-grade PostgreSQL configuration
- Set up proper backup strategies
-
Create a new Django app:
make migrations # If you have a running container # or python manage.py startapp <app_name>
-
Add the app to
INSTALLED_APPSin settings -
Create and run migrations:
make migrations make migrate
The project follows Django best practices and PEP 8 guidelines.
Currently, the project includes:
- Django Admin interface (accessible at
/admin/) - Basic Django models structure
- REST API endpoints (to be implemented)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Django documentation
- Review the Docker logs:
make app-logs - Check database connectivity:
make postgres
To update the project:
- Pull the latest changes
- Update dependencies:
poetry update - Run migrations:
make migrate - Restart services:
make app-down && make app
Happy coding! π