0

This is my code to load EditScreen for User Model.

@login_required ()            
def getUser (request, userId):

    if request.method  == "GET":
        my_record = User.objects.get(user_id=userId)
        form = UserUpdateForm (instance=my_record)

        print "Registration page loading..."

        return render(request, "EN/updateuser.html", {'form': form } )

But 'user_id' (PrimaryKey) is not going as part of 'form' when I get request for update User I'm not able to get the object instance to update it. How to set it along with the form so that I should be able to read it. I thought of setting it through Hidden Value but I felt that is not a safe way.

Please suggest.

4

1 回答 1

0

为什么要将其作为表单的一部分发送?您已经在 URL 中拥有它(因此作为userId视图的参数),无需从其他任何地方获取它。

于 2013-08-23T18:56:43.733 回答