Django:添加特定模型实例的权限 [英] Django: Adding Permission to an Specific Model Instance

查看:137
本文介绍了Django:添加特定模型实例的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找实现用户权限以允许用户编辑特定模型实例的最佳方法。

I am looking for the best way to implement user permissions to allow users to edit specific model instances.

例如,我有这两个模型:


For instance, I have such two models:

model RadioChannel(models.Model):
    name = models.CharField(max_length=150, unique= True)
    number = models.IntegerField( unique= True)

model ProgramSchedule(models.Model):
    channel = models.ForeignKey("RadioChannel")
    name = models.CharField(max_length=150, unique= True)
    start_time = models.DateTimeField()

我的操作员是我内置的Django用户。我想为这些用户创建组,以便他们只能添加/删除/编辑允许的ProgramSchedules。另外我想向这些用户添加组到管理面板。

Now my Operators are my build-in Django users. I want to make groups for these users so that they can only add/remove/edit ProgramSchedules that are allowed. In addition I want to add groups to these users to the admin panel.

谢谢。

推荐答案

您正在寻找对象权限实现。一个很好的比较是:
http://djangopackages.com/grids/g/perms/

You are looking for an object permission implementation. A good comparison is here: http://djangopackages.com/grids/g/perms/

无耻的插件:
我的一个非常受欢迎的每个对象许可应用程序的分支: http://github.com/azizmb/django-authority

这篇关于Django:添加特定模型实例的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆