django - permission_required not working on view -


i have problem permissions on view of django.

my code on view.py:

@login_required(login_url='/kullanicigirisi/') @permission_required('reservationapp.change_reservation', login_url='/') def rezervasyonduzenle(request, id): 

there 2 app: app1: userlogin, app2: reservationapp

i assigned permissions on userlogin , used permission_required on reservationapp

assignments:

  username = request.post['username']   password = request.post['password']   user = authenticate(username=username, password=password)   pr = permission.objects.get(codename='change_reservation')   group = group.objects.get(name='rol1')   group.permissions.add(pr)   usern = user.objects.get(username=username)   usern.groups.add(group) 

permission_required not working, everytime return login_url :/ have idea problem?

if you're being redirected login_url, either user not logged in, or user doesn't have permission reservationapp.change_reservation. can narrow down of case?

if you're not sure what's going on, remove @permission_required decorator locally, , put near top (or use import pdb; pdb.set_trace()).

def rezervasyonduzenle(request, id):     print request.user.is_authenticated()     print request.user.user_permissions.all() 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -