我在 django 中有这段代码,当我在控制台中打印它时,它输出 user_id = 1 和 request.user.id = 1
所以url是http://127.0.0.1:8000/upload/picturelist/1
,这使得user_id = 1,然后我登录到我在django中启动我的项目时创建的超级用户request.user.id = 1
为什么我会被拒绝?
def pictureList(request, user_id):
if user_id != request.user.id:
print "%s, %s " % (user_id, request.user.id)
raise PermissionDenied
picture_list = Picture.objects.filter(user=user_id)
print "%s, %s " % (user_id, request.user.id)