Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
97d3321e
Kaydet (Commit)
97d3321e
authored
May 15, 2019
tarafından
Jon Dufresne
Kaydeden (comit)
Carlton Gibson
May 15, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Changed tuple choices to list in docs.
üst
717362d8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
27 additions
and
27 deletions
+27
-27
coding-style.txt
docs/internals/contributing/writing-code/coding-style.txt
+5
-5
actions.txt
docs/ref/contrib/admin/actions.txt
+2
-2
widgets.txt
docs/ref/forms/widgets.txt
+6
-6
conditional-expressions.txt
docs/ref/models/conditional-expressions.txt
+2
-2
fields.txt
docs/ref/models/fields.txt
+6
-6
managers.txt
docs/topics/db/managers.txt
+2
-2
models.txt
docs/topics/db/models.txt
+2
-2
modelforms.txt
docs/topics/forms/modelforms.txt
+2
-2
No files found.
docs/internals/contributing/writing-code/coding-style.txt
Dosyayı görüntüle @
97d3321e
...
...
@@ -258,17 +258,17 @@ Model style
* ``def get_absolute_url()``
* Any custom methods
* If ``choices`` is defined for a given model field, define each choice as
a tuple of tuples, with an all-uppercase name as a class attribute on the
model.
Example::
* If ``choices`` is defined for a given model field, define each choice as
a
list of tuples, with an all-uppercase name as a class attribute on the model.
Example::
class MyModel(models.Model):
DIRECTION_UP = 'U'
DIRECTION_DOWN = 'D'
DIRECTION_CHOICES =
(
DIRECTION_CHOICES =
[
(DIRECTION_UP, 'Up'),
(DIRECTION_DOWN, 'Down'),
)
]
Use of ``django.conf.settings``
===============================
...
...
docs/ref/contrib/admin/actions.txt
Dosyayı görüntüle @
97d3321e
...
...
@@ -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)
...
...
docs/ref/forms/widgets.txt
Dosyayı görüntüle @
97d3321e
...
...
@@ -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')]
...
...
docs/ref/models/conditional-expressions.txt
Dosyayı görüntüle @
97d3321e
...
...
@@ -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(
...
...
docs/ref/models/fields.txt
Dosyayı görüntüle @
97d3321e
...
...
@@ -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
...
...
docs/topics/db/managers.txt
Dosyayı görüntüle @
97d3321e
...
...
@@ -161,7 +161,7 @@ For example::
class Person(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
role = models.CharField(max_length=1, choices=
(('A', _('Author')), ('E', _('Editor')))
)
role = models.CharField(max_length=1, choices=
[('A', _('Author')), ('E', _('Editor'))]
)
people = models.Manager()
authors = AuthorManager()
editors = EditorManager()
...
...
@@ -261,7 +261,7 @@ custom ``QuerySet`` if you also implement them on the ``Manager``::
class Person(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
role = models.CharField(max_length=1, choices=
(('A', _('Author')), ('E', _('Editor')))
)
role = models.CharField(max_length=1, choices=
[('A', _('Author')), ('E', _('Editor'))]
)
people = PersonManager()
This example allows you to call both ``authors()`` and ``editors()`` directly from
...
...
docs/topics/db/models.txt
Dosyayı görüntüle @
97d3321e
...
...
@@ -161,13 +161,13 @@ ones:
A choices list looks like this::
YEAR_IN_SCHOOL_CHOICES =
(
YEAR_IN_SCHOOL_CHOICES =
[
('FR', 'Freshman'),
('SO', 'Sophomore'),
('JR', 'Junior'),
('SR', 'Senior'),
('GR', 'Graduate'),
)
]
The first element in each tuple is the value that will be stored in the
database. The second element is displayed by the field's form widget.
...
...
docs/topics/forms/modelforms.txt
Dosyayı görüntüle @
97d3321e
...
...
@@ -165,11 +165,11 @@ Consider this set of models::
from django.db import models
from django.forms import ModelForm
TITLE_CHOICES =
(
TITLE_CHOICES =
[
('MR', 'Mr.'),
('MRS', 'Mrs.'),
('MS', 'Ms.'),
)
]
class Author(models.Model):
name = models.CharField(max_length=100)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment