Introduction
We recently undertook a significant migration across our five Django projects to streamline development, improve code quality, and automate deployments. This process involved adopting several modern Python tools and updating our operational practices.
Key Migrations & Best Practices Implemented
1. From Pip to UV (The Speed Upgrade)
We replaced pip and pip-tools with uv, a next-generation package manager written in Rust. uv provides blazing-fast dependency resolution and installation. We standardized on uv sync --active for production deployments, resulting in significantly faster deployment times.
2. Consolidating Linters with Ruff
We retired older tools (flake8, isort, django-lint, black) in favor of the all-in-one ruff linter and formatter. Ruff is highly configurable via pyproject.toml and enforces code standards efficiently.
3. Robust Pre-Commit Hooks
We configured .pre-commit-config.yaml to run Ruff (lint and format) automatically before every commit. This proactive quality control prevents stylistic errors from entering the Python codebase.
4. Enhanced Deployment Automation
Our existing project_manager.sh script was updated to use uv sync --active, handle custom firstletter_env virtual environment paths, manage the uwsgi dependency, and reliably deploy from the new main branch. This script automates fetching code, running migrations and static collection, loading fixtures, and restarting services.
5. Standardization
We standardized branch naming from master to main across all repositories and environments for a modern, clear workflow.
These changes provide a foundation for highly efficient, secure, and automated development and deployment of all our Django websites.