so I want to make permission of the classes based on the user’s group.
example I have many groups like
(‘Student’,‘Doctors’,‘Geology’,‘Civil engineer’)
I have this class
class Div_EP(LoginRequiredMixin, PermissionRequiredMixin, ListView):
permission_required = ('Doctors','Civil engineer')
model = Botomeqpts
template_name = 'Home/Div_EP.html'
so the users allowed to visit this page are , Doctors and Civil engineer only.
How I correct this in this class?
The appropriate mechanism for handling this is to identify an appropriate permission (perhaps view_botomeqpts?) or create a new permission (e.g. list_botomeqpts) and assign that permission to the Doctors and Civil engineer groups. Your view then checks for that permission.
Also, you don’t need the LoginRequiredMixin, because the AnonymousUser isn’t going to pass the permission_required test. (LoginRequiredMixin and PermissionRequiredMixin both call the AccessMixin.handle_no_permission method, so there’s no difference in what’s going to happen if the permissions aren’t present.)
Then you’ve got something wrong somewhere along the line. Either you don’t have the right permission assigned to the group, you don’t have the user assigned to the group, or you don’t have the right app.codename for that permission in the permission_required field. Check all your data and data assignments.