summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2019-05-15 05:31:42 -0700
committerCarlton Gibson <carlton.gibson@noumenal.es>2019-05-15 14:31:42 +0200
commit97d3321e89c8d4434927bdbc308db1ccffa99d3b (patch)
tree47e830992ae4c1007a4962051d0ac64c7c6c4bb2 /docs/ref
parent717362d810955b9514e2ccd989f8a1647c9d7a00 (diff)
Changed tuple choices to list in docs.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/contrib/admin/actions.txt4
-rw-r--r--docs/ref/forms/widgets.txt12
-rw-r--r--docs/ref/models/conditional-expressions.txt4
-rw-r--r--docs/ref/models/fields.txt12
4 files changed, 16 insertions, 16 deletions
diff --git a/docs/ref/contrib/admin/actions.txt b/docs/ref/contrib/admin/actions.txt
index f0c8be7728..3956ecb93c 100644
--- a/docs/ref/contrib/admin/actions.txt
+++ b/docs/ref/contrib/admin/actions.txt
@@ -47,11 +47,11 @@ simple news application with an ``Article`` model::
from django.db import models
- STATUS_CHOICES = (
+ STATUS_CHOICES = [
('d', 'Draft'),
('p', 'Published'),
('w', 'Withdrawn'),
- )
+ ]
class Article(models.Model):
title = models.CharField(max_length=100)
diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt
index 40f9e52f65..0e701babeb 100644
--- a/docs/ref/forms/widgets.txt
+++ b/docs/ref/forms/widgets.txt
@@ -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')]
diff --git a/docs/ref/models/conditional-expressions.txt b/docs/ref/models/conditional-expressions.txt
index 80146917d7..f9e681f667 100644
--- a/docs/ref/models/conditional-expressions.txt
+++ b/docs/ref/models/conditional-expressions.txt
@@ -21,11 +21,11 @@ We'll be using the following model in the subsequent examples::
REGULAR = 'R'
GOLD = 'G'
PLATINUM = 'P'
- ACCOUNT_TYPE_CHOICES = (
+ ACCOUNT_TYPE_CHOICES = [
(REGULAR, 'Regular'),
(GOLD, 'Gold'),
(PLATINUM, 'Platinum'),
- )
+ ]
name = models.CharField(max_length=50)
registered_on = models.DateField()
account_type = models.CharField(
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index fbcba2bd66..ff650851d7 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -89,12 +89,12 @@ these choices instead of the standard text field.
The first element in each tuple is the actual value to be set on the model,
and the second element is the human-readable name. For example::
- YEAR_IN_SCHOOL_CHOICES = (
+ YEAR_IN_SCHOOL_CHOICES = [
('FR', 'Freshman'),
('SO', 'Sophomore'),
('JR', 'Junior'),
('SR', 'Senior'),
- )
+ ]
Generally, it's best to define choices inside a model class, and to
define a suitably-named constant for each value::
@@ -106,12 +106,12 @@ define a suitably-named constant for each value::
SOPHOMORE = 'SO'
JUNIOR = 'JR'
SENIOR = 'SR'
- YEAR_IN_SCHOOL_CHOICES = (
+ YEAR_IN_SCHOOL_CHOICES = [
(FRESHMAN, 'Freshman'),
(SOPHOMORE, 'Sophomore'),
(JUNIOR, 'Junior'),
(SENIOR, 'Senior'),
- )
+ ]
year_in_school = models.CharField(
max_length=2,
choices=YEAR_IN_SCHOOL_CHOICES,
@@ -130,7 +130,7 @@ will work anywhere that the ``Student`` model has been imported).
You can also collect your available choices into named groups that can
be used for organizational purposes::
- MEDIA_CHOICES = (
+ MEDIA_CHOICES = [
('Audio', (
('vinyl', 'Vinyl'),
('cd', 'CD'),
@@ -142,7 +142,7 @@ be used for organizational purposes::
)
),
('unknown', 'Unknown'),
- )
+ ]
The first element in each tuple is the name to apply to the group. The
second element is an iterable of 2-tuples, with each 2-tuple containing