Ticket #10845: partial_modelform_note.diff

File partial_modelform_note.diff, 1.1 KB (added by Andy Durdin, 16 years ago)

Docs patch

  • docs/topics/forms/modelforms.txt

     
    326326    for the missing, but required fields, or use ``save(commit=False)`` and
    327327    manually set any extra required fields::
    328328
    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',)
    332333
    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()
    336337
     338        # or:
     339
     340        author = form.save(commit=False)
     341        author.title = 'MR'
     342        new_author = author.save()
     343
    337344    See the `section on saving forms`_ for more details on using
    338345    ``save(commit=False)``.
    339346
Back to Top