This was used to replace all the instances of old Media URLs with new ones, but could be used for any kind of text search/replace across Django objects.
- Change the model import to whatever your app and model is.
- Set the
to_findandto_replacestrings to whatever you need. - Change
Postto your model name, and the fields to whatever field(s) you want to search and replace across.
I pasted all this into the Django shell to run it as I only needed it once.
To run it again you can then just change to_find and to_replace and run
the same Post.objects.update... again.