Ticket #5364: 5364.2.diff

File 5364.2.diff, 1.1 KB (added by Philippe Raoult, 12 years ago)

modified the doc accordingly, with input from #django-sprint

  • docs/newforms.txt

     
    18731873.. note::
    18741874
    18751875    If you specify ``fields`` when creating a form with ``form_for_model()``,
    1876     make sure that the fields that are *not* specified can provide default
    1877     values, or are allowed to have a value of ``None``. If a field isn't
    1878     specified on a form, the object created from the form can't provide
    1879     a value for that attribute, which will prevent the new instance from
    1880     being saved.
     1876    the fields that are *not* specified will not be set by the form's ``save()``
     1877    method. If any of those fields requires an explicit value ``save()`` will fail.
     1878    In that case you can call ``form.save(commit=False)`` to get an instance
     1879    with only the fields from the form which you can update yourself before saving::
     1880           
     1881            instance = form.save(commit=False)
     1882            instance.required_field = 'my_value'
     1883            instance.save()
    18811884
    18821885Overriding the default field types
    18831886~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Back to Top