Hello everyone, I encountered such a problem in django == 1.8.14, python 2.7:
I use the decorator @permission_required to distribute access to the pages. but in all cases error 403 is returned, as if these rights do not exist.
Who faced similar, tell me how to solve
views.py
from django.shortcuts import render from django.contrib.auth.decorators import login_required, permission_required @permission_required('add_post') def new_post(request): return render(request, 'new.html') Checked the presence of rights inside the view (without decorator) in the following way:
p = Permission.objects.get(name = 'Can add post') print p.codename # add_post print request.user.user_permissions.all() # все права юзера if request.user.user_permissions.get(codename=p.codename): print 'OK' else: print 'NO' Output OK