Skip to content

A minimal, modern Django 5 base template configured with Docker, PostgreSQL, and uv for dependency management.

Notifications You must be signed in to change notification settings

omaryesith/django5-base-template

Repository files navigation

Django 5 Base Template

A minimal, modern Django 5 base template configured with Docker, PostgreSQL, and uv for dependency management.

Features

  • Django 5.0+
  • Docker & Docker Compose
  • PostgreSQL
  • uv for fast dependency management
  • Split Settings (Base, Dev, Staging, Production)
  • Environment Variables via .env

Getting Started

1. Clone and Initialize

Clone this repository and run the initialization script. This script will rename the project, set up the .env file, and generate a secure secret key.

./init_project.sh my_awesome_project

The script will:

  1. Rename the project_name directory to my_awesome_project.
  2. Update all references in manage.py, wsgi.py, asgi.py, and settings.
  3. Create .env from .env.example.
  4. Generate a new DJANGO_SECRET_KEY and update .env.
  5. Set PROJECT_NAME and DJANGO_SETTINGS_MODULE in .env.

2. Run with Docker

Build and start the containers:

docker compose up --build

The application will be available at http://localhost:8000.

Internationalization (i18n)

This project is configured with internationalization support.

Usage

To mark strings for translation in your code, use gettext_lazy:

from django.utils.translation import gettext_lazy as _

class MyModel(models.Model):
    name = models.CharField(_("Name"), max_length=100)

Managing Translations

  1. Make Messages: Scans your code for translatable strings and creates/updates .po files.

    docker compose exec web uv run python manage.py makemessages -l es
  2. Compile Messages: Compiles .po files into .mo files for use by Django.

    docker compose exec web uv run python manage.py compilemessages

Rosetta

Rosetta is installed in the development environment to facilitate translation management.

  1. Ensure your development server is running.
  2. Navigate to http://localhost:8000/rosetta/.
  3. You can edit translations directly from this interface.

3. Dependency Management

This project uses uv to manage dependencies and when running on Docker we use docker compose exec [web container name] to run commands.

  • Add a dependency:

    docker compose exec web uv add <package>
  • Sync dependencies:

    docker compose exec web uv sync
  • Run a command:

    docker compose exec web uv run python manage.py migrate

About

A minimal, modern Django 5 base template configured with Docker, PostgreSQL, and uv for dependency management.

Resources

Stars

Watchers

Forks