summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorZach Borboa <zachborboa@gmail.com>2016-10-19 06:55:21 -0700
committerTim Graham <timograham@gmail.com>2016-10-19 09:56:13 -0400
commit3f730457d861a661079832792e5085378464a8ff (patch)
treef168d5ec248347364c7f7a876a4afc4ed0c22352 /docs/ref
parent5677129b06410fe3cf214d962e4b6115cc647d34 (diff)
[1.10.x] Fixed #27361 -- Used "from django import forms" in forms api docs.
Backport of 90c3b11e873a326219a68c14a3b5dca0181e7b3c from master
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/forms/api.txt32
1 files changed, 16 insertions, 16 deletions
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt
index c9e627ddcc..be0a1bed7f 100644
--- a/docs/ref/forms/api.txt
+++ b/docs/ref/forms/api.txt
@@ -388,11 +388,11 @@ When the ``Form`` is valid, ``cleaned_data`` will include a key and value for
fields. In this example, the data dictionary doesn't include a value for the
``nick_name`` field, but ``cleaned_data`` includes it, with an empty value::
- >>> from django.forms import Form
- >>> class OptionalPersonForm(Form):
- ... first_name = CharField()
- ... last_name = CharField()
- ... nick_name = CharField(required=False)
+ >>> from django import forms
+ >>> class OptionalPersonForm(forms.Form):
+ ... first_name = forms.CharField()
+ ... last_name = forms.CharField()
+ ... nick_name = forms.CharField(required=False)
>>> data = {'first_name': 'John', 'last_name': 'Lennon'}
>>> f = OptionalPersonForm(data)
>>> f.is_valid()
@@ -523,7 +523,7 @@ it calls its ``as_table()`` method behind the scenes::
>>> f = ContactForm()
>>> f.as_table()
'<tr><th><label for="id_subject">Subject:</label></th><td><input id="id_subject" type="text" name="subject" maxlength="100" required /></td></tr>\n<tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" required /></td></tr>\n<tr><th><label for="id_sender">Sender:</label></th><td><input type="email" name="sender" id="id_sender" required /></td></tr>\n<tr><th><label for="id_cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="id_cc_myself" /></td></tr>'
- >>> print(f.as_table())
+ >>> print(f)
<tr><th><label for="id_subject">Subject:</label></th><td><input id="id_subject" type="text" name="subject" maxlength="100" required /></td></tr>
<tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" required /></td></tr>
<tr><th><label for="id_sender">Sender:</label></th><td><input type="email" name="sender" id="id_sender" required /></td></tr>
@@ -546,9 +546,9 @@ attributes to required rows or to rows with errors: simply set the
:attr:`Form.error_css_class` and/or :attr:`Form.required_css_class`
attributes::
- from django.forms import Form
+ from django import forms
- class ContactForm(Form):
+ class ContactForm(forms.Form):
error_css_class = 'error'
required_css_class = 'required'
@@ -1147,14 +1147,14 @@ example, ``BeatleForm`` subclasses both ``PersonForm`` and ``InstrumentForm``
(in that order), and its field list includes the fields from the parent
classes::
- >>> from django.forms import Form
- >>> class PersonForm(Form):
- ... first_name = CharField()
- ... last_name = CharField()
- >>> class InstrumentForm(Form):
- ... instrument = CharField()
- >>> class BeatleForm(PersonForm, InstrumentForm):
- ... haircut_type = CharField()
+ >>> from django import forms
+ >>> class PersonForm(forms.Form):
+ ... first_name = forms.CharField()
+ ... last_name = forms.CharField()
+ >>> class InstrumentForm(forms.Form):
+ ... instrument = forms.CharField()
+ >>> class BeatleForm(InstrumentForm, PersonForm):
+ ... haircut_type = forms.CharField()
>>> b = BeatleForm(auto_id=False)
>>> print(b.as_ul())
<li>First name: <input type="text" name="first_name" required /></li>