Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: Adding Permission to an Specific Model Instance

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()

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.

Thanks.

like image 631
Hellnar Avatar asked Nov 02 '10 08:11

Hellnar


1 Answers

I would recommend using Django Guardian for object-level permissions.

like image 143
Kevin London Avatar answered Oct 12 '22 01:10

Kevin London