I ran into almost the same problem, and here is my solution (adapted to your case):
views.py
class MyModelDeleteView(DeleteView): model=MyModel @method_decorator(permission_required_or_403('myapp.delete_mymodel', (MyModel, 'slug', 'slug'), accept_global_perms=True)) def dispatch(self, *args, **kwargs): return super(MyModelDeleteView, self).dispatch(*args, **kwargs)
Please note that you can pass the accept_global_perms parameter, i.e. False by default. It allows users with 'myapp.delete_mymodel' to allow deletion of any object of the MyModel class. This can be useful, for example, for moderators.
Documentation of custodians Decorators .
source share