Reusing an object from a context after submitting a form
This is not related to django. It's how the web works. HTTP is stateless.
When you generate the page, you've finished with that task.
The model instance is destroyed.
When the user submits the form or sends the modifications in any other way, a new connection starts with a new request and a new context.
At this point you need to re-instance the object to modify.
Depends on the application and the model itself.
You can pass the unique_id of the object, if it has one, and get it back in your actual context querying for it.
I'm trying to do something that may appear to be simple, but I can't figure it out. As always, django surprises me with its complexity...
My view generates an instance of a model and "passes it on" in a context to a template. On that template, the user fills a form and submits it. And this is what should happen next: the object that was in the context when the page loaded is modified a bit and submitted in a context once again (to the same template). However, I can't get the instance of the object that was in the context when the page loaded. Is it possible to do? Maybe as a hidden input? Or with some fancy django function? Any other idea is appreciated as well, even workarounds (it's not really a professional project, I'm doing it for fun and for experience).
I'm sorry if this question is stupid, but I'm new to django and my brain still has troubles with understanding everything. Thanks for your help!