Do:
form = MyFormClass(instance=my_object)
Your form will need to be a ModelForm
, see the docs for more information!
Question
It appears that there's no way for me to get an ORM object with numerous select_related
objects and create a Form
and run my data through all the cleaning and additional validations I have.
I'm simply trying to reduce the number of queries that get executed, the form either takes an id
and re-creates the object, or does not take advantage of the additional fields (I've tried using model_to_dict
)
Is there anything I'm missing? How can I use select_related inside of a form?
Django 1.4
Solution
Do:
form = MyFormClass(instance=my_object)
Your form will need to be a ModelForm
, see the docs for more information!