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
babe9e64
Kaydet (Commit)
babe9e64
authored
Tem 11, 2017
tarafından
Irindu Indeera
Kaydeden (comit)
Tim Graham
Tem 11, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28352 -- Corrected QuerySet.values_list() return type in docs examples.
üst
f816ceed
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
conditional-expressions.txt
docs/ref/models/conditional-expressions.txt
+4
-4
querysets.txt
docs/ref/models/querysets.txt
+5
-5
models.txt
docs/topics/db/models.txt
+1
-1
No files found.
docs/ref/models/conditional-expressions.txt
Dosyayı görüntüle @
babe9e64
...
@@ -110,7 +110,7 @@ A simple example::
...
@@ -110,7 +110,7 @@ A simple example::
... output_field=CharField(),
... output_field=CharField(),
... ),
... ),
... ).values_list('name', 'discount')
... ).values_list('name', 'discount')
[('Jane Doe', '0%'), ('James Smith', '5%'), ('Jack Black', '10%')]
<QuerySet [('Jane Doe', '0%'), ('James Smith', '5%'), ('Jack Black', '10%')]>
``Case()`` accepts any number of ``When()`` objects as individual arguments.
``Case()`` accepts any number of ``When()`` objects as individual arguments.
Other options are provided using keyword arguments. If none of the conditions
Other options are provided using keyword arguments. If none of the conditions
...
@@ -132,7 +132,7 @@ the ``Client`` has been with us, we could do so using lookups::
...
@@ -132,7 +132,7 @@ the ``Client`` has been with us, we could do so using lookups::
... output_field=CharField(),
... output_field=CharField(),
... )
... )
... ).values_list('name', 'discount')
... ).values_list('name', 'discount')
[('Jane Doe', '5%'), ('James Smith', '0%'), ('Jack Black', '10%')]
<QuerySet [('Jane Doe', '5%'), ('James Smith', '0%'), ('Jack Black', '10%')]>
.. note::
.. note::
...
@@ -153,7 +153,7 @@ registered more than a year ago::
...
@@ -153,7 +153,7 @@ registered more than a year ago::
... When(account_type=Client.PLATINUM, then=a_year_ago),
... When(account_type=Client.PLATINUM, then=a_year_ago),
... ),
... ),
... ).values_list('name', 'account_type')
... ).values_list('name', 'account_type')
[('Jack Black', 'P')]
<QuerySet [('Jack Black', 'P')]>
Advanced queries
Advanced queries
================
================
...
@@ -182,7 +182,7 @@ their registration dates. We can do this using a conditional expression and the
...
@@ -182,7 +182,7 @@ their registration dates. We can do this using a conditional expression and the
... ),
... ),
... )
... )
>>> Client.objects.values_list('name', 'account_type')
>>> Client.objects.values_list('name', 'account_type')
[('Jane Doe', 'G'), ('James Smith', 'R'), ('Jack Black', 'P')]
<QuerySet [('Jane Doe', 'G'), ('James Smith', 'R'), ('Jack Black', 'P')]>
Conditional aggregation
Conditional aggregation
-----------------------
-----------------------
...
...
docs/ref/models/querysets.txt
Dosyayı görüntüle @
babe9e64
...
@@ -634,20 +634,20 @@ respective field or expression passed into the ``values_list()`` call — so the
...
@@ -634,20 +634,20 @@ respective field or expression passed into the ``values_list()`` call — so the
first item is the first field, etc. For example::
first item is the first field, etc. For example::
>>> Entry.objects.values_list('id', 'headline')
>>> Entry.objects.values_list('id', 'headline')
[(1, 'First entry'), ...]
<QuerySet [(1, 'First entry'), ...]>
>>> from django.db.models.functions import Lower
>>> from django.db.models.functions import Lower
>>> Entry.objects.values_list('id', Lower('headline'))
>>> Entry.objects.values_list('id', Lower('headline'))
[(1, 'first entry'), ...]
<QuerySet [(1, 'first entry'), ...]>
If you only pass in a single field, you can also pass in the ``flat``
If you only pass in a single field, you can also pass in the ``flat``
parameter. If ``True``, this will mean the returned results are single values,
parameter. If ``True``, this will mean the returned results are single values,
rather than one-tuples. An example should make the difference clearer::
rather than one-tuples. An example should make the difference clearer::
>>> Entry.objects.values_list('id').order_by('id')
>>> Entry.objects.values_list('id').order_by('id')
[(1,), (2,), (3,), ...]
<QuerySet[(1,), (2,), (3,), ...]>
>>> Entry.objects.values_list('id', flat=True).order_by('id')
>>> Entry.objects.values_list('id', flat=True).order_by('id')
[1, 2, 3, ...]
<QuerySet [1, 2, 3, ...]>
It is an error to pass in ``flat`` when there is more than one field.
It is an error to pass in ``flat`` when there is more than one field.
...
@@ -682,7 +682,7 @@ Similarly, when querying a reverse foreign key, ``None`` appears for entries
...
@@ -682,7 +682,7 @@ Similarly, when querying a reverse foreign key, ``None`` appears for entries
not having any author::
not having any author::
>>> Entry.objects.values_list('authors')
>>> Entry.objects.values_list('authors')
[('Noam Chomsky',), ('George Orwell',), (None,)]
<QuerySet [('Noam Chomsky',), ('George Orwell',), (None,)]>
.. versionchanged:: 1.11
.. versionchanged:: 1.11
...
...
docs/topics/db/models.txt
Dosyayı görüntüle @
babe9e64
...
@@ -229,7 +229,7 @@ ones:
...
@@ -229,7 +229,7 @@ ones:
>>> fruit.name = 'Pear'
>>> fruit.name = 'Pear'
>>> fruit.save()
>>> fruit.save()
>>> Fruit.objects.values_list('name', flat=True)
>>> Fruit.objects.values_list('name', flat=True)
['Apple', 'Pear']
<QuerySet ['Apple', 'Pear']>
:attr:`~Field.unique`
:attr:`~Field.unique`
If ``True``, this field must be unique throughout the table.
If ``True``, this field must be unique throughout the table.
...
...
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