Skip to content

Django startproject template with batteries and nice tooling.

License

Notifications You must be signed in to change notification settings

oliverandrich/django-startproject

Repository files navigation

django-startproject

Screenshot of the landing page

Django startproject template with batteries and nice tooling.

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.

Features

Development tools

Install

$ django-admin startproject \
      --extension=py,toml,sh \
      --exclude=.hidden \
      --template=https://github.com/oliverandrich/django-startproject/archive/main.zip \
      example_project

# Setup environment and install dependencies
$ just bootstrap

# Migrate database
$ just migrate

# Start dev server
$ just runserver

Usage

# Bootstrap the project and install dependencies
just bootstrap

# Upgrade/install all dependencies defined in pyproject.toml
just upgrade

# Run database migrations
just migrate

# Create database migrations
just makemigrations

# Start debugserver
just runserver
# or
just debugserver

# Start the interactive django shell
just shell

# Start manage.py for all cases not covered by other commands
just manage ...

# Run pre-commit rules on all files
just lint

# Run test suite
just test

# run test suite with code coverage analysis
just coverage 

Environemt Variables for Docker and your .env file

Or when run as a 12-Factor application.

Environment Variable Default Location
ALLOWED_HOSTS [] settings.py
CACHE_URL "locmem://" settings.py
CSRF_TRUSTED_ORIGINS [] settings.py
DATABASE_URL "sqlite:///db.sqlite3" settings.py
DEBUG False settings.py
EMAIL_URL "console:" settings.py
INTERNAL_IPS [] settings.py
LANGUAGE_CODE  "EN" settings.py
SECRET_KEY get_random_secret_key() settings.py
TAILWIND_CLI_PATH "~/.local/bin" settings.py
TIME_ZONE  "UTC" settings.py
GRANIAN_WORKERS 1 entrypoint.sh
GRANIAN_THREADS 1 entrypoint.sh
GRANIAN_* see https://github.com/emmett-framework/granian entrypoint.sh

Docker and docker-compose

The docker/Dockerfile uses a multi stage process to embrace caching for building the container images.

Contributing

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