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
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
- go to http://localhost:8000/ and do good work!
- to see the vite/react index page, head to http://localhost:8000/react
- the frontend TypeScript code is under
core/frontend/src/
- the frontend TypeScript code is under
to deploy using disco, create a new github repo with your new directory, and refer to the disco Django+SQLite docs.
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 softeros.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 servingcore
default/main app with a mini/
function view & template file- the necessary files to deploy this using disco
- I suggest you setup & use Black and Pyright via text editor packages. Black should auto-format on save. TODO add black via pre-commit
- https://12factor.net/ - started "it" all where "it" stands for good web app deployment practices
- https://github.com/cookiecutter/cookiecutter-django - exactly like this, "Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly" - but too much-y for my taste. it's great! I just wanted my own so I made this.
- https://github.com/jefftriplett/django-startproject - similar to this as well
- other ones: djangox, django-react-boilerplate, Django Material Kit
this project was initially created during my time at the Recurse Center. thanks to Rob Simmons for the contributions!
Footnotes
-
because you only get one chance ↩