This is a code-heavy blog post about a specific pattern/third party library. I wanted to document the behaviours that other Django developers need to expect if they are not super careful when introducing a concept called soft deletion.
Soft deletion, on the face of it, is a neat thing to be able to do. Say you have to write an application to track books in a library. You might create a Book model in your database and have a Loan object that refers to it.
If you work with Python you should try Jupyter notebooks. A particularly nice service I was introduced to recently is http://mybinder.org - which sets up a notebook server for you, installs whatever you need on it, and lets you (and anyone you care to share a link with) run python, from a web browser. Your code becomes reproducible and tinkerable by anyone, anywhere, without the usual barriers of clone, install, set up.
A post about Python programming with a tongue-twisting title…
Most Python projects rely on libraries (packages) from elsewhere, in particular from PyPI. Although it means you have to manually check for new versions of this third-party code, it’s a good idea to explicitly “pin” the version of each dependency, and this is usually done in a file called requirements.txt. This way, you know that what you use in development is the same as what you deploy.