AFAIK, permissions do not filter the queryset.
So, if i have to filter the queryset and return relevant records, what are permissions for? Is there something permission does which filtering cannot?
AFAIK, permissions do not filter the queryset.
So, if i have to filter the queryset and return relevant records, what are permissions for? Is there something permission does which filtering cannot?
Let me give an example to explain the difference in a simple way. Assume that you want to build a student management system to be used by both teachers and students. You want to implement a web page that lists the students. But you want to adapt two restrictions while doing that:
If the logged-in user is a student, do not show any students as it might violate privacy. This can be done by Django's built-in permissions.
If the logged-in user is a teacher, do not list all students, but only who are registered to that teacher's course. This is object-level permission and Django does not have a built-in library for that. You can either implement this logic by yourself or use libraries such as django-guardian.