I have:
class MyModel(models.Model):
fk = models.ForeignKey(AnotherModel)
field = models.PositiveIntegerField()
class MyForm((forms.ModelForm):
class Meta:
model = MyModel
Now I want to create a form to edit an existing MyModel instance. But
I don't know the pk of the instance. However I do now the value of fk
& field, which together should be enough to uniquely identify an
instance.
So I do:
z = MyModel.objects.get(fk=o, field=f)
f = MyForm(instance=z)
And the form f does have the correct data of z pre-populated.
However when I submitted the form, a new MyModel object was created
instead of just updating z.
What do I need to do to create a form that would update z?
--
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en.