mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Changed tuple choices to list in docs.
This commit is contained in:
parent
717362d810
commit
97d3321e89
8 changed files with 27 additions and 27 deletions
|
@ -57,12 +57,12 @@ widget on the field. In the following example, the
|
|||
|
||||
from django import forms
|
||||
|
||||
BIRTH_YEAR_CHOICES = ('1980', '1981', '1982')
|
||||
FAVORITE_COLORS_CHOICES = (
|
||||
BIRTH_YEAR_CHOICES = ['1980', '1981', '1982']
|
||||
FAVORITE_COLORS_CHOICES = [
|
||||
('blue', 'Blue'),
|
||||
('green', 'Green'),
|
||||
('black', 'Black'),
|
||||
)
|
||||
]
|
||||
|
||||
class SimpleForm(forms.Form):
|
||||
birth_year = forms.DateField(widget=forms.SelectDateWidget(years=BIRTH_YEAR_CHOICES))
|
||||
|
@ -90,14 +90,14 @@ changing :attr:`ChoiceField.choices` will update :attr:`Select.choices`. For
|
|||
example::
|
||||
|
||||
>>> from django import forms
|
||||
>>> CHOICES = (('1', 'First',), ('2', 'Second',))
|
||||
>>> CHOICES = [('1', 'First'), ('2', 'Second')]
|
||||
>>> choice_field = forms.ChoiceField(widget=forms.RadioSelect, choices=CHOICES)
|
||||
>>> choice_field.choices
|
||||
[('1', 'First'), ('2', 'Second')]
|
||||
>>> choice_field.widget.choices
|
||||
[('1', 'First'), ('2', 'Second')]
|
||||
>>> choice_field.widget.choices = ()
|
||||
>>> choice_field.choices = (('1', 'First and only',),)
|
||||
>>> choice_field.widget.choices = []
|
||||
>>> choice_field.choices = [('1', 'First and only')]
|
||||
>>> choice_field.widget.choices
|
||||
[('1', 'First and only')]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue