I posed this question on IRC and was told to direct it here because it
might be "interesting".
I created a ModelForm with additional fields which aren't present on
the model. Now, I want to use this form to edit an instance of the
model, but there doesn't seem to be a way set the additional fields
via the bound instance. Simple example of what I was thinking:
<code>
class MyModel(models.Model):
field_a = ....
field_b = ....
class MyModelForm(forms.ModelForm):
field_c = ...
class Meta:
model = MyModel
mymodel = MyModel()
mymodel.field_a = "A"
mymodel.field_b = "B"
mymodel.field_c = "C"
myform = MyModelForm(instance=mymodel)
</code>
Printing <code>myform</code> would fill the widgets for field_a,
field_b, field_c with "A", "B", and "C", respectively.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---