Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats the difference between DjangoModelPermissions and DjangoObjectPermissions

Whats the difference between DjangoModelPermissions and DjangoObjectPermissions?

I'm still learning Django and DRF and according to the docs, they seems to do exactly the same thing.

DjangoModelPermissions: This permission class ties into Django's standard django.contrib.auth model permissions.


DjangoObjectPermissions This permission class ties into Django's standard object permissions framework that allows per-object permissions on models

For the later, it seems like it has something to do with Django’s permission framework foundation which has no implementation. and apparently, django-guardian fills in this gap.

In Django admin, I'm able to assign a Model's CRUD permission to users and groups, so what does the later add?

I'm trying to wrap my head around this permission system. What are the differences and what should I know about them?

like image 383
Krimson Avatar asked Dec 22 '22 23:12

Krimson


1 Answers

DjangoModelPermissions is all about permissions to interact with a database table which are represented as models in code while DjangoObjectPermissions are permissions to interact with individual rows in the table which are model instances in code. Basically, the object permissions are granular permissions which give access to some rows in a table but can restrict access to other rows in the same table

like image 107
Ken4scholars Avatar answered Apr 29 '23 18:04

Ken4scholars