First things first: I don’t think you should use my Django project template for your Django projects. In fact, much like with dotfiles, I don’t think you should ever just use someone else’s template. In the spirit of Yes Minister’s irregular verbs: “I make careful and opinionated curations, you make poor choices, they add pointless bloat”.
What can be useful though, is using them for inspiration and ideas, and I definitely think mine has some things worth taking.
I’m really quite happy with my test setup. Roughly, it’s:
- Generate a Django project with the cookiecutter
- Run the tests of the created project
- Ensure 100% test coverage
- Use honcho to run Django via the Procfile and test that it’s started ok
Unfortunately it turns out running the WSGI server with honcho with tox with CircleCI leads to some fun with paths / CWD, and I thus don’t yet have
gunicorn working with the test suite, but hopefully I’ll work that out soon!
The generated project has one test, and here it is:
1 2 3 4 5
That one little test is my favourite – five lines exercising so much: does (most of) the service start, are the settings ok, is the root URL config ok, and more.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
I keep my Django workspace as a subdirectory of the git root.
This keeps my Django project isolated from other bits of metadata; equivalent to a
src dir, if you will.
Necessary? Nope. Objective benefits? Not really. Do I like it and recommend it for the compartmentalisation? Sure.
I need to fix my
and sort out
django-secure, but that’s pretty much it for “things I use in everything”.
Would you recommend anything else? Drop me a tweet!