Go from a new environment to starting a Django project before your coffee cools!
I put all my Django best practices into this starter repository so you can start building right away.
This will help you:
- Run tests and Django Security Check via GitHub Actions
- Work faster with a self-documenting Makefile tailored to Django
- Format files before committing with pre-commit
- Get Python 3.9, Pip, Pipenv, and Django installed in a new environment
- Work with a .gitignore tailored to Python and Django development
- Set up and link a Docker Postgres database
git clone https://github.com/victoriadrake/django-starter
./env-setup.sh
(It's always a good idea to read scripts before running them! If you don't, well, thanks for the Bitcoin.)
Do make install
to install dependencies in a virtual environment.
If you'd like help installing just Django via Pipenv, run ./django-setup.sh
.
You can now do make dev
to see a pretty welcome page at http://localhost:8000/
and test that everything's working properly.
Start building! If you're new to Django, check out their great tutorials.
Run make help
to see what else I've got set up for you.
Over the years I've been developing with Django, I've built up a suite of developer tools, practices that help make programmers more efficient, and lots of little tips and ideas that make building with Django easier.
I've written about a lot of these, and wanted to make it easier for you to use them too!
You can take advantage of automation to relieve developers of having to remember to run linting, tests, and other routine actions. The use of pre-commit and flows like GitHub Actions can help to keep your codebase consistent, tested, and easier to develop.
- This pre-commit configuration helps to format code and documentation, and even check for accidentally committed credentials!
- I've included GitHub Actions for running your test suite and Django Security Check on pull requests.
Instead of the default settings.py
, I use a settings directory with separate files for local and production environment settings. This helps avoid misconfiguration mishaps!
You can pass the settings file as an argument, for example when running the development server:
python manage.py runserver --settings=app.settings.local
The Makefile command make dev
uses this. Speaking of...
Imagine having a super helpful, project-specific CLI that neatly remembers all your typical development actions for you. For example, instead of typing...
pipenv run coverage run python manage.py test app --verbosity=0 --parallel --failfast
You can just do:
make test
Isn't that better? I think so! Check out the self-documenting Makefile to see how it makes other everyday actions easier. (Why's it self-documenting? Just type make help
and see.)
Have something to add? Feel free to open a pull request!