I am thinking about how I can use PermissionRequiredMixin in FBV.(I have used the same in CBV and it is working as expected).
Please find the FBV(here need to implement permission). I don't want to use @login_required()
@login_required()
This will check only if the user is authenticated or not.
def delete_viewgen(request,PermissionRequiredMixin,id):
oneuser=ShiftChange.objects.get(id=id)
permission_required = ('abc.add_shiftchange',)
oneuser.delete()# delete
return redirect('/gensall')
I am getting ERROR : missing 1 required positional argument: 'PermissionRequiredMixin'
CBV Case where it is working fine.
class ShiftChangeUpdateView(PermissionRequiredMixin,UpdateView):
permission_required = ('abc.change_shiftchange',)
login_url = '/login/'
model=ShiftChange
fields='__all__'
In CBV it is working fine and if user is not having change permission it is giving 403 Forbidden how to implement same in FBV and also how to customize 403 Forbidden message.
Thanks!
question from:
https://stackoverflow.com/questions/65650217/how-to-use-permissionrequiredmixin-in-fbv 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…