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 existing model instance and then save it. Here is the ModelForm (stripped considerably from the original in my attempts to identify the cause of this problem):
class TempRuleFieldForm(ModelForm):
class Meta:
model = RuleField
and here is the code I'm running:
>>> m = RuleField.objects.get(pk=1)
>>> f = TempRuleFieldForm(instance=m)
>>> f.is_valid()
False
The model object (m
above) is valid and it saves just fine, but the form will not validate. Now, as far as I can tell, this code is identical to the Django docs example found here: http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method, though obviously I am missing something. I would greatly appreciate some fresh eyes to tell me what I've got wrong.
Thanks