Awesome
django-hatch-startproject
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
- Django 4.2.x
- django-browser-reload
- django-environ
- django-htmx
- django-tailwind-cli
- whitenoise
- SQLite setup with WAL mode enabled (See
config/__init__.py
.) - Argon2 password hashing is activated
- Local install of htmx.
- uses the single folder Django project layout
Development tools
- django-types
- model-bakery
- pytest
- pytest-cov
- pytest-django
- pytest-mock
- pre-commit setup inspired by Boost your Django DX
- sane ruff configuration
- syrupy for snapshot testing
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.