diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2019-12-23 05:47:13 -0800 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-12-23 14:48:16 +0100 |
| commit | eb40426259cbfd8c4d25797c878424542cf1a1a7 (patch) | |
| tree | 2eaeee44b77b8e1a0e829baa7a0f1cafcdb8f6b6 /docs/topics/forms | |
| parent | 1e45b06cfd87c4866a201202200ae888a8b8e259 (diff) | |
[3.0.x] Removed unnecessary code-block directives in various docs.
Backport of 5e00bd1f7717149573df9607b848297a520881d3 from master
Diffstat (limited to 'docs/topics/forms')
| -rw-r--r-- | docs/topics/forms/modelforms.txt | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt index ea7f9f2df7..5c3dd19aa7 100644 --- a/docs/topics/forms/modelforms.txt +++ b/docs/topics/forms/modelforms.txt @@ -318,9 +318,7 @@ Every ``ModelForm`` also has a ``save()`` method. This method creates and saves a database object from the data bound to the form. A subclass of ``ModelForm`` can accept an existing model instance as the keyword argument ``instance``; if this is supplied, ``save()`` will update that instance. If it's not supplied, -``save()`` will create a new instance of the specified model: - -.. code-block:: python +``save()`` will create a new instance of the specified model:: >>> from myapp.models import Article >>> from myapp.forms import ArticleForm @@ -373,9 +371,7 @@ exists in the database. To work around this problem, every time you save a form using ``commit=False``, Django adds a ``save_m2m()`` method to your ``ModelForm`` subclass. After you've manually saved the instance produced by the form, you can invoke -``save_m2m()`` to save the many-to-many form data. For example: - -.. code-block:: python +``save_m2m()`` to save the many-to-many form data. For example:: # Create a form instance with POST data. >>> f = AuthorForm(request.POST) @@ -394,9 +390,7 @@ you've manually saved the instance produced by the form, you can invoke Calling ``save_m2m()`` is only required if you use ``save(commit=False)``. When you use a ``save()`` on a form, all data -- including many-to-many data -- -is saved without the need for any additional method calls. For example: - -.. code-block:: python +is saved without the need for any additional method calls. For example:: # Create a form instance with POST data. >>> a = Author() @@ -898,9 +892,7 @@ Saving objects in the formset ----------------------------- As with a ``ModelForm``, you can save the data as a model object. This is done -with the formset's ``save()`` method: - -.. code-block:: python +with the formset's ``save()`` method:: # Create a formset instance with POST data. >>> formset = AuthorFormSet(request.POST) @@ -918,9 +910,7 @@ excluded), these fields will not be set by the ``save()`` method. You can find more information about this restriction, which also holds for regular ``ModelForms``, in `Selecting the fields to use`_. -Pass ``commit=False`` to return the unsaved model instances: - -.. code-block:: python +Pass ``commit=False`` to return the unsaved model instances:: # don't save to the database >>> instances = formset.save(commit=False) |
