How to permissions to a group in Django 1.8?

329 views Asked by At

I have a 'Document' model which has many-to-many relationship with User model.There is a separate web page in my project which displays the Document instance in a text editor.

Now suppose user who created one document wants to invite other users to this document.But he wants to give read-only permission to some and read-write permission to others.

How do I implement this permission functionality in Django?How do groups and other permissions frameworks work in Django?

1

There are 1 answers

0
sadaf2605 On

Django Group and Permission applies on model itself. So for a specific entry of document if you want to give access to user in that case you need to change your schema of Document model. Just add a users_who_can_read=ManyToMany(Users), users_who_can_write=ManyToMany(Users), and at your view.py when a user is trying to load a page just check if he is in users_who_can_read or not.

I think it should solve your problem without much problem.