Django developers,
I recently disabled .delete() in querysets in all managers in my project, after encountering a bug in a bulk delete queryset in my tests [
https://code.djangoproject.com/ticket/31600]. Actually it was quite simple to disable .delete() in querysets, but I had to define my own QuerySet class:
class QuerySet(models.query.QuerySet):
def delete(self):
raise NotImplementedError("delete is not implemented.")
I also disabled bulk_create() in managers for similar reasons. And I thought, maybe you can introduce optional settings in which if it's set, will disable delete() and bulk_create() in managers and querysets? I think this may be useful, since the delete() and bulk_create() methods have problems - they don't call the model's methods and in some cases (such as in my case) related objects from other models don't get deleted (with delete()) and models don't get validated (with bulk_create()).
I also call each model's self.full_clean() method before saving, which may also be a setting in Django. I don't want invalid objects to be saved to the database.
If you think this is a good idea and want me to implement it, I can try to submit a PR.
By the way, I checked and I found out that I can still delete objects from our admin interface, so it probably doesn't use the delete() queryset.
Thanks,
Uri.