I overrode the delete_queryset
method to add a condition before being able to delete a model. It looks like this:
def delete_queryset(self, request, queryset):
if condition_is_not_met:
self.message_user(request, 'Error', level=messages.ERROR)
return
super().delete_queryset(request, queryset)
This DOES prevent the deletion but it shows that error message and below it says, Successfully deleted 'x' objects
(Again, not deleted so success message should not be there). I don't want to display that error message and what would be even better is if the confirmation page did not even show up if the condition is not met (This is a bonus though). Any suggestions?