Used PEP 8 style indentation in forms docs.
This commit is contained in:
parent
64033fd085
commit
b9bf61ce61
|
@ -363,8 +363,10 @@ example::
|
||||||
if cc_myself and subject:
|
if cc_myself and subject:
|
||||||
# Only do something if both fields are valid so far.
|
# Only do something if both fields are valid so far.
|
||||||
if "help" not in subject:
|
if "help" not in subject:
|
||||||
raise forms.ValidationError("Did not send for 'help' in "
|
raise forms.ValidationError(
|
||||||
"the subject despite CC'ing yourself.")
|
"Did not send for 'help' in the subject despite "
|
||||||
|
"CC'ing yourself."
|
||||||
|
)
|
||||||
|
|
||||||
In this code, if the validation error is raised, the form will display an
|
In this code, if the validation error is raised, the form will display an
|
||||||
error message at the top of the form (normally) describing the problem.
|
error message at the top of the form (normally) describing the problem.
|
||||||
|
|
|
@ -55,9 +55,11 @@ widget on the field. In the following example, the
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
BIRTH_YEAR_CHOICES = ('1980', '1981', '1982')
|
BIRTH_YEAR_CHOICES = ('1980', '1981', '1982')
|
||||||
FAVORITE_COLORS_CHOICES = (('blue', 'Blue'),
|
FAVORITE_COLORS_CHOICES = (
|
||||||
|
('blue', 'Blue'),
|
||||||
('green', 'Green'),
|
('green', 'Green'),
|
||||||
('black', 'Black'))
|
('black', 'Black'),
|
||||||
|
)
|
||||||
|
|
||||||
class SimpleForm(forms.Form):
|
class SimpleForm(forms.Form):
|
||||||
birth_year = forms.DateField(widget=forms.SelectDateWidget(years=BIRTH_YEAR_CHOICES))
|
birth_year = forms.DateField(widget=forms.SelectDateWidget(years=BIRTH_YEAR_CHOICES))
|
||||||
|
@ -364,8 +366,11 @@ foundation for custom widgets.
|
||||||
widget.value_from_datadict(data, files, name + '_%s' % i)
|
widget.value_from_datadict(data, files, name + '_%s' % i)
|
||||||
for i, widget in enumerate(self.widgets)]
|
for i, widget in enumerate(self.widgets)]
|
||||||
try:
|
try:
|
||||||
D = date(day=int(datelist[0]), month=int(datelist[1]),
|
D = date(
|
||||||
year=int(datelist[2]))
|
day=int(datelist[0]),
|
||||||
|
month=int(datelist[1]),
|
||||||
|
year=int(datelist[2]),
|
||||||
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return ''
|
return ''
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue