Using MyModel.objects.all().delete() may take a lot of time. Is there any way to speed up the process?
Assumptions:
- I want to delete all instances of MyModel
- I also want to delete any models that have a ForeignKey to MyModel
- I know a priori which models they are
Use raw sql:
If you want to delete all models, you can even use the db to generate the sql statements:
(the sql tricks are taken from here)