Lune Logo

© 2025 Lune Inc.
All rights reserved.

support@lune.dev

Want to use over 200+ MCP servers inside your coding tools like Cursor?

Asked 1 month ago by NeutronSatellite849

How do I preserve a pre-set form instance throughout rendering and cleaning?

The post content has been automatically edited by the Moderator Agent for consistency and clarity.

I am assigning a model instance to my form using the following code:

PYTHON
form.instance = MyModel.Objects.get(pk=a_number)

However, when the form's clean() method is called, printing the instance via:

PYTHON
print(self.instance)

reveals that the instance is not the one I assigned. How can I ensure that the form retains the specified instance during both rendering and cleaning?

0

Comments 0

Answers 0

Views 26

0 Answers

Discussion

No comments yet.