Home

Awesome

django-hatch-startproject

Screenshot of the landing page

I took the inspiration from Jeff Triplett's django-startproject and created my own starter for a fresh django project. It includes the batteries I use regularly. 🤷‍♂️

The template is also inspired by Carlton Gibson's Post The Single Folder Django Project Layout. It uses the single folder layout as a start as I always run in the same situation Carlton describes in his post. If you have to split the project into several apps, you can always call python manage.py startapp later on.

Out of the box SQLite is configured, but you can easily activate MySQL or Postgres support by turning on the corresponding features in the pyproject.toml file.

Features

Development tools

Install

django-admin startproject \
    --extension=ini,py,toml,yaml,yml \
    --template=https://github.com/oliverandrich/django-hatch-startproject/archive/main.zip \
    example_project

# Setup environment
cd example_project
echo "DJANGO_DEBUG=True" >> .env
echo "SECRET_KEY=notsosecret" >> .env

# Install dependencies
hatch env create

# Migrate database
hatch run migrate

# Start dev server
hatch run runserver

Add Postgres support

To activate Postgres support edit the pyproject.toml and change the default environment to look like the following snippet.

# Default environment
[tool.hatch.envs.default]
dependencies = ["django-types", "ipdb", "model-bakery"]
features = [
  # Uncomment the next line to add the MySQL dependencies
  # "mysql",
  # Uncomment the next line to add the Postgres dependencies
  "postgres",
]

Set the environment variable DATABASE_URL to something reasonable

Add MySQL support

To activate Postgres support edit the pyproject.toml and change the default environment to look like the following snippet.

# Default environment
[tool.hatch.envs.default]
dependencies = ["django-types", "ipdb", "model-bakery"]
features = [
  # Uncomment the next line to add the MySQL dependencies
  "mysql",
  # Uncomment the next line to add the Postgres dependencies
  # "postgres",
]

Set the environment variable DATABASE_URL to something reasonable

Contributing

Contributions, issues and feature requests are welcome! Feel free to check issues page.