Skip to content

gregsadetsky/minimalish-django-starter

Repository files navigation

Minimalish Django Starter Kit

intro

Minimalish is a Django Project Template. It's an opiniated, deployment-ready, "good enough" starting point that includes most of everything you'd want to have in a Django project:

  • dev / prod environment separation
  • environment variables (per the classic 12factor) with fallback to .env (useful on dev)
  • static file serving
  • integration of the frontend bundler Vite so that you can combine a TypeScript frontend with a Django backend. this is great for React projects, which most frontend projects are these days.
    • you also don't have to use Vite or write a TypeScript frontend -- the classic Django html templating still works fine.
  • all of the necessary files to deploy your site using disco

how to do it

copy & paste the code below to start a new Django project based on this template:

echo -n "what's your project name (short, lowercase-only, no spaces or hyphens, etc.)? "
read PROJECTNAME
mkdir $PROJECTNAME
cd $PROJECTNAME
python3 -m venv venv
source venv/bin/activate
pip install Django==5.1
django-admin startproject --template=https://github.com/gregsadetsky/minimalish-django-starter/archive/main.zip -n .env.example -n README.starter.md -n serve.sh $PROJECTNAME .
pip install -r requirements.txt
git init
mv starter $PROJECTNAME
mv README.starter.md README.md
cp .env.example .env
mkdir core/frontend/static
python manage.py migrate
(cd core/frontend && npm install)

then:

  • fill out the DJANGO_SECRET_KEY value in the .env file
  • in one terminal, start the Django backend server with python manage.py runserver
  • in another terminal:
cd core/frontend
npm run dev

to deploy using disco, create a new github repo with your new directory, and refer to the disco Django+SQLite docs.

more technical info

Minimalish uses:

  • Django 5.1
  • python 3.10/.11 ish
  • pip / venv / requirements.txt
  • .env configuration files on developers' machines using python-dotenv
  • os-level env vars on production
  • dev/prod separation in the settings
  • integration of Vite using django-vite
  • a custom user model1
  • use of os.environ[] rather than the softer os.getenv() which by design silently fails. if an env var can't be found, that's a problem that needs addressing
  • whitenoise for static file serving
  • core default/main app with a mini / function view & template file
  • the necessary files to deploy this using disco

more extra bonus things

  • I suggest you setup & use Black and Pyright via text editor packages. Black should auto-format on save. TODO add black via pre-commit

other resources

credit

this project was initially created during my time at the Recurse Center. thanks to Rob Simmons for the contributions!

Footnotes

  1. because you only get one chance