是否可以仅对我的模型的m2m字段授予删除权限? 让我们想想:
class Site(models.Model):
name = models.CharField(max_length=50)
favourited_by = models.ManyToManyField(User)
如果我编写此模型资源:
class SiteResource(ModelResource):
class Meta:
queryset = Site.objects.all()
resource_name = 'Site'
allowed_methods = ['post', 'get', 'delete']
我为整个模型授予了删除权限,但我只希望能够从“favorited\ u by”字段中删除条目。有什么办法可以做到吗
根据定义,在该端点上执行删除操作应删除整个对象
但是,如果您正在寻找一个自定义行为,那么您可以用如下内容覆盖
obj_delete
:相关问题 更多 >
编程相关推荐