class UserDataUpdateView(UpdateView):
    model = models.AuthorityData

def get_form_kwargs(self):
    kwargs = super(UserDataUpdateView, self).get_form_kwargs()
kwargs.update({'request': self.request})
return kwargs

def get_object(self, queryset=None):
    obj = super(UserDataUpdateView, self).get_object(queryset)
if not user_has_access(obj, self.request):
    raise Http404('Access Denied')
return obj
Object level permissions in Django admin