Possibly a newbie question, so please bear with me.
I have a Django form that edits a certain instance of a Model. In order to know which object is being edited, I have a hidden field containing the id of the object, along with the URL containing the id.
First question: Is having the id of the object in a hidden field the right way of doing it?
My (possibly unfounded) concern with having it only as part of the url is that someone could then open the page of one object id, submit the form to another, and that object will then be overwritten. That's why I'm trying to use a hidden field.
The problem with storing the id in a hidden field is that, on validation of the form, Django complains that the object does not have an unique id (obviously).
Second question: If a unique field is part of a form, how does one tell Django to ignore the fact that that key already exists, in order to update the object?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…