Django: Permissions based on Model Instance
Asked Answered
C

3

13

I have a model class Project and for each model instance, there should be a 'group' of users who may edit that instance. I guess I could add another model class called ProjectEditor to add those editors. Is there a better way of implementing this? What about checking for permissions? I would need to write my own permission method then too, right?

Thanks Eric

Correspond answered 8/8, 2010 at 16:51 Comment(0)
C
3

Model (table) level permissions can be achieved using the groups facility provided by Django auth. Groups let you create custom permissions at a model level. Instance (row) level would be trickier. You would most likely have to write a custom mechanism to accomplish this.

Here is a Django Snippet that might give you some ideas.

Chivy answered 8/8, 2010 at 17:25 Comment(0)
E
15

Django Guardian seems to be the best solution today for Model instance level permissions.

Eccrine answered 19/12, 2013 at 15:36 Comment(0)
C
3

Model (table) level permissions can be achieved using the groups facility provided by Django auth. Groups let you create custom permissions at a model level. Instance (row) level would be trickier. You would most likely have to write a custom mechanism to accomplish this.

Here is a Django Snippet that might give you some ideas.

Chivy answered 8/8, 2010 at 17:25 Comment(0)
N
2

There was an open source release for row/object level permissions by the washington times team that might be of use:

Nineteen answered 8/8, 2010 at 18:15 Comment(1)
@DanAbramov: Try code.osuosl.org/projects/object-permissions where you can find the 1.3.1 release from March.Nineteen

© 2022 - 2024 — McMap. All rights reserved.