我有新闻模型。我想通过属于这些组的用户来管理新闻?
class News(models.Model):
    title = models.CharField(max_length=255, help_text="Short title of news")
    content = models.TextField(blank=True)
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    created_on = models.DateTimeField(auto_now_add=True)
    updated_on = models.DateTimeField(auto_now=True)
    status = models.BooleanField(default=True)如何定义这些用户权限?
Users Groups        Permissions
Reporters       # create a news
CopyEditors     # read and update
Poducers        # read, update, aprove and revoke
Rundown         # list of aproved articles
Anchors         # read only aproved articles发布于 2020-06-09 23:33:16
您需要向模型中添加自定义权限。一些已经定义的权限是add,delete,change和delete.But在这里你需要添加自定义权限。
class News(models.Model):
  title = models.CharField(max_length=255, help_text="Short title of news")
  content = models.TextField(blank=True)
  author = models.ForeignKey(User, on_delete=models.CASCADE)
  created_on = models.DateTimeField(auto_now_add=True)
  updated_on = models.DateTimeField(auto_now=True)
  status = models.BooleanField(default=True)
  class Meta:
     permissions = (
        ('custom_permission', 'title goes here'),
    )必须读取这些
https://stackoverflow.com/questions/62283677
复制相似问题