| 1926 | | make sure that the fields that are *not* specified can provide default |
|---|
| 1927 | | values, or are allowed to have a value of ``None``. If a field isn't |
|---|
| 1928 | | specified on a form, the object created from the form can't provide |
|---|
| 1929 | | a value for that attribute, which will prevent the new instance from |
|---|
| 1930 | | being saved. |
|---|
| | 1926 | then the fields that are *not* specified will not be set by the form's |
|---|
| | 1927 | ``save()`` method. Django will prevent any attempt to save an incomplete |
|---|
| | 1928 | model, so if the model does not allow the missing fields to be empty, and |
|---|
| | 1929 | does not provide a default value for the missing fields, any attempt to |
|---|
| | 1930 | ``save()`` a ``form_for_model`` with missing fields will fail. To avoid |
|---|
| | 1931 | this failure, you must use ``save(commit=False)`` and manually set any |
|---|
| | 1932 | extra required fields:: |
|---|
| | 1933 | |
|---|
| | 1934 | instance = form.save(commit=False) |
|---|
| | 1935 | instance.required_field = 'new value' |
|---|
| | 1936 | instance.save() |
|---|
| | 1937 | |
|---|
| | 1938 | See the `section on saving forms`_ for more details on using |
|---|
| | 1939 | ``save(commit=False)``. |
|---|
| | 1940 | |
|---|
| | 1941 | .. _section on saving forms: `The save() method`_ |
|---|