2
我在django的這個代碼,當我在控制檯打印它輸出USER_ID = 1和request.user.id = 1django python有條件不工作?
所以URL是http://127.0.0.1:8000/upload/picturelist/1
,這使得USER_ID = 1,那麼我已登錄的到我創建的超級用戶,當我在django開始我的項目時,它是request.user.id = 1
爲什麼我會得到permissionDenied?
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)
謝謝,我添加int()user_id,它的工作。如果int(user_id)!= request.user.id: – user2387135