I can\'t figure out why the permission required decorator isn\'t working. I would like to allow access to a view only for staff members. I have tried
@permission
By the way, if you're using class-based views, you should wrap your decorator in the method_decorator
decorator (go figure):
class MyView(DetailView):
...
@method_decorator(permission_required('polls.can_vote', login_url=reverse_lazy('my_login')))
def dispatch(self, request, *args, **kwargs):
.... blah ....
class MyModel(models.Model):
...
def has_perm(self perm, obj=None):
if perm == 'polls.canvote':
return self.can_vote()