0

i have News model. i want to manage news by users who belongs from these Groups?

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)

how can i define these user permissions?

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

Root 007
  • 7
  • 1
  • 5

1 Answers1

0

You need to add custom permissions into your model. Some permissions already defined which are add,delete,change and delete.But here you need to add custom permissions.

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'),

    )

Must read these

Assign object permissions

Model and Permissions

Add a custom permission