Ok, I have been staring at this for hours trying to figure out what\'s going on, to no avail. I am trying to create a ModelForm using the \'instance\' keyword to pass it an exi
Note that your link doesn't call f.is_valid()
, it just saves directly. This is potentially a bit misleading.
The point is that instantiating a form with just an instance
parameter but no data
does not bind it to data, and the form is therefore not valid. You will see that f.is_bound
is False.
Behind the scenes, instance
is really just the same as passing initial
data, which as the docs note is only used to display the data initially and is not used for saving. You would probably benefit from reading the notes on bound and unbound forms.