def get_queryset(self, ignore_filters=False): # raise exception if no permission check_permission(self.model, 'view') queryset = super().get_queryset() if ignore_filters is False: queryset = queryset.filter(self.get_filter()) return queryset
def save(self, force_insert=False, force_update=False, using=None, update_fields=None, *args, **kwargs): if self.pk is None: check_permission(self, 'add') else: check_permission(self, 'change') super().save(force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)
def delete(self, using=None, keep_parents=False, *args, **kwargs): check_permission(self, 'delete') super().delete(using=using, keep_parents=keep_parents)
def update(self, **kwargs): # raise exception if no permission check_permission(self.model, 'change') return super().update(**kwargs)
def bulk_update(self, objs, fields, batch_size=None): # raise exception if no permission check_permission(self.model, 'change') return super().update(objs, fields, batch_size=batch_size)
def bulk_create(self, objs, batch_size=None, ignore_conflicts=False): # raise exception if no permission check_permission(self.model, 'add') return super().bulk_create(objs, batch_size=batch_size, ignore_conflicts=ignore_conflicts)
def delete(self): # raise exception if no permission check_permission(self.model, 'delete') return super().delete()