diff options
Diffstat (limited to 'docs/topics/forms')
| -rw-r--r-- | docs/topics/forms/formsets.txt | 10 | ||||
| -rw-r--r-- | docs/topics/forms/index.txt | 16 | ||||
| -rw-r--r-- | docs/topics/forms/media.txt | 7 | ||||
| -rw-r--r-- | docs/topics/forms/modelforms.txt | 19 |
4 files changed, 24 insertions, 28 deletions
diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt index 84635457ff..8a630f6c9f 100644 --- a/docs/topics/forms/formsets.txt +++ b/docs/topics/forms/formsets.txt @@ -569,8 +569,8 @@ Adding additional fields to a formset If you need to add additional fields to the formset this can be easily accomplished. The formset base class provides an ``add_fields`` method. You -can simply override this method to add your own fields or even redefine the -default fields/attributes of the order and deletion fields:: +can override this method to add your own fields or even redefine the default +fields/attributes of the order and deletion fields:: >>> from django.forms import BaseFormSet >>> from django.forms import formset_factory @@ -651,9 +651,9 @@ This is useful if you want to :ref:`use more than one formset in a view Using a formset in views and templates ====================================== -Using a formset inside a view is as easy as using a regular ``Form`` class. -The only thing you will want to be aware of is making sure to use the -management form inside the template. Let's look at a sample view:: +Using a formset inside a view is not very different from using a regular +``Form`` class. The only thing you will want to be aware of is making sure to +use the management form inside the template. Let's look at a sample view:: from django.forms import formset_factory from django.shortcuts import render diff --git a/docs/topics/forms/index.txt b/docs/topics/forms/index.txt index 6cf1570ab0..b6c6df0c16 100644 --- a/docs/topics/forms/index.txt +++ b/docs/topics/forms/index.txt @@ -26,11 +26,11 @@ allow a visitor to do things like enter text, select options, manipulate objects or controls, and so on, and then send that information back to the server. -Some of these form interface elements - text input or checkboxes - are fairly -simple and are built into HTML itself. Others are much more complex; an -interface that pops up a date picker or allows you to move a slider or -manipulate controls will typically use JavaScript and CSS as well as HTML form -``<input>`` elements to achieve these effects. +Some of these form interface elements - text input or checkboxes - are built +into HTML itself. Others are much more complex; an interface that pops up a +date picker or allows you to move a slider or manipulate controls will +typically use JavaScript and CSS as well as HTML form ``<input>`` elements to +achieve these effects. As well as its ``<input>`` elements, a form must specify two things: @@ -326,8 +326,7 @@ telling it where to go next. The template ~~~~~~~~~~~~ -We don't need to do much in our ``name.html`` template. The simplest example -is: +We don't need to do much in our ``name.html`` template: .. code-block:: html+django @@ -671,8 +670,7 @@ Useful attributes on ``{{ field }}`` include: Outputs a ``<ul class="errorlist">`` containing any validation errors corresponding to this field. You can customize the presentation of the errors with a ``{% for error in field.errors %}`` loop. In this - case, each object in the loop is a simple string containing the error - message. + case, each object in the loop is a string containing the error message. ``{{ field.is_hidden }}`` This attribute is ``True`` if the form field is a hidden field and diff --git a/docs/topics/forms/media.txt b/docs/topics/forms/media.txt index 398a4538b1..c88679dda6 100644 --- a/docs/topics/forms/media.txt +++ b/docs/topics/forms/media.txt @@ -16,7 +16,7 @@ Calendar widget. This widget can then be associated with the CSS and JavaScript that is required to render the calendar. When the Calendar widget is used on a form, Django is able to identify the CSS and JavaScript files that are required, and provide the list of file names -in a form suitable for easy inclusion on your Web page. +in a form suitable for inclusion on your Web page. .. admonition:: Assets and Django Admin @@ -49,7 +49,7 @@ The easiest way to define assets is as a static definition. Using this method, the declaration is an inner ``Media`` class. The properties of the inner class define the requirements. -Here's a simple example:: +Here's an example:: from django import forms @@ -362,8 +362,7 @@ are part of the form:: <script type="text/javascript" src="http://static.example.com/whizbang.js"></script> If you want to associate additional assets with a form -- for example, -CSS for form layout -- simply add a ``Media`` declaration to the -form:: +CSS for form layout -- add a ``Media`` declaration to the form:: >>> class ContactForm(forms.Form): ... date = DateField(widget=CalendarWidget) diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt index d8b137f624..56ab59fda2 100644 --- a/docs/topics/forms/modelforms.txt +++ b/docs/topics/forms/modelforms.txt @@ -389,9 +389,8 @@ you've manually saved the instance produced by the form, you can invoke >>> f.save_m2m() Calling ``save_m2m()`` is only required if you use ``save(commit=False)``. -When you use a simple ``save()`` on a form, all data -- including -many-to-many data -- is saved without the need for any additional method calls. -For example: +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 @@ -731,8 +730,8 @@ to make:: >>> from myapp.models import Book >>> BookForm = modelform_factory(Book, fields=("author", "title")) -This can also be used to make simple modifications to existing forms, for -example by specifying the widgets to be used for a given field:: +This can also be used to make modifications to existing forms, for example by +specifying the widgets to be used for a given field:: >>> from django.forms import Textarea >>> Form = modelform_factory(Book, form=BookForm, @@ -755,8 +754,8 @@ Model formsets .. class:: models.BaseModelFormSet Like :doc:`regular formsets </topics/forms/formsets>`, Django provides a couple -of enhanced formset classes that make it easy to work with Django models. Let's -reuse the ``Author`` model from above:: +of enhanced formset classes to make working with Django models more +convenient. Let's reuse the ``Author`` model from above:: >>> from django.forms import modelformset_factory >>> from myapp.models import Author @@ -786,8 +785,8 @@ with the ``Author`` model. It works just like a regular formset:: :func:`~django.forms.models.modelformset_factory` uses :func:`~django.forms.formsets.formset_factory` to generate formsets. This - means that a model formset is just an extension of a basic formset that - knows how to interact with a particular model. + means that a model formset is an extension of a basic formset that knows + how to interact with a particular model. Changing the queryset --------------------- @@ -952,7 +951,7 @@ extra forms displayed. Also, ``extra=0`` doesn't prevent creation of new model instances as you can :ref:`add additional forms with JavaScript <understanding-the-managementform>` -or just send additional POST data. Formsets `don't yet provide functionality +or send additional POST data. Formsets `don't yet provide functionality <https://code.djangoproject.com/ticket/26142>`_ for an "edit only" view that prevents creation of new instances. |
