I am using django-braces MixIns. I have set-up permissions for my user groups. and i have this Class Based View :
class ReportList(views.LoginRequiredMixin, views.PermissionRequiredMixin, ListView):
permission_required = "auth.damage-report-list"
model = DamageReport
template_name = 'panel/reports.html'
paginate_by = 10
is_paginated = True
def get_context_data(self, **kwargs):
context = super(ReportList, self).get_context_data(**kwargs)
for obj in context['object_list']:
obj.alerts = DamageAlert.objects.filter(report__pk=obj.id)
return context
As you can see i have added the LoginRequiredMixin and PermissionRequiredMixin. I also added a "Permission_required" field with the permission code name. I login as the user which has the required permission and i get redirected to a login screen. Any idea what could be going wrong here ?.
P.S : Is there anyway to redirect the user to a "Not authorized" page if he does not have the required permission ?.
Thanks!
Ok my problem was an innocent one. for some reason i put auth. before the permission code instead of my app name which is panel
like this : "panel.damage-report-list"
Everything works. however i would still like to redirect to a special page when no authorization is available.