Someone accidentally deleted an instance and all the related objects (through the Django admin) in production. I have a backup of the database, so I can get those data back, but I would like to do it with a script rather than copy the data manually, since it includes a lot of related objects.
I would like to retrieve the item that has been deleted (I do have its model and its pk, so I can do MyModel.objects.get(pk=123456)
), but also all its related objects (ForeignKey
, ManyToMany
...) in a way to re-import them in the production database.
It can be either in SQL or any serialized format, to use loaddata
. How can I do that?