Ticket #10845: partial_modelform_note.diff
File partial_modelform_note.diff, 1.1 KB (added by , 16 years ago) |
---|
-
docs/topics/forms/modelforms.txt
326 326 for the missing, but required fields, or use ``save(commit=False)`` and 327 327 manually set any extra required fields:: 328 328 329 instance = Instance(required_field='value') 330 form = InstanceForm(request.POST, instance=instance) 331 new_instance = form.save() 329 class PartialAuthorForm(ModelForm): 330 class Meta: 331 model = Author 332 fields = ('name',) 332 333 333 instance = form.save(commit=False)334 instance.required_field = 'new value'335 new_ instance = instance.save()334 author = Author(title='MR') 335 form = PartialAuthorForm(request.POST, instance=author) 336 new_author = form.save() 336 337 338 # or: 339 340 author = form.save(commit=False) 341 author.title = 'MR' 342 new_author = author.save() 343 337 344 See the `section on saving forms`_ for more details on using 338 345 ``save(commit=False)``. 339 346