Say you have a bunch of developers that occasionally need Django shell access to production, but you want this to be an exceptional event. Here is a drop-in replacement for ./manage.py shell that defaults to read-only mode, but lets the developer switch to writable mode on the fly, while notifying the team.
The strategy here is to use Django's database router mechanism to throw an exception when trying to write to the database.
Drop this into your project as myapp/management/commands/shell.py and it will over-ride the default shell command.
In my case, I'm notifying the team via Hipchat. Of course, you can replace this function with a version that sends out an email, etc. If you're curious, here is the hipchat code:
I'm currently working at NerdWallet, a startup in San Francisco trying to bring clarity to all of life's financial decisions. We're hiring like crazy. Hit me up on Twitter, I would love to talk.