Ticket #5364: 5364.diff

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

modified the doc accordingly

  • docs/newforms.txt

    18731873.. note::
    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 should call ``form.save(commit=False)`` which will return
     1879    an instance with only the fields from the form::
     1881            instance = form.save(commit.False)
     1882            instance.required_field = 'my_value'
     1883            instance.save()
    18821885Overriding the default field types
Back to Top