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
617d5f41
Kaydet (Commit)
617d5f41
authored
Ock 28, 2018
tarafından
priyanshsaxena
Kaydeden (comit)
Tim Graham
Ock 31, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29066 -- Allowed negating query expressions.
üst
6b2f8fb9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
3 deletions
+17
-3
AUTHORS
AUTHORS
+1
-0
expressions.py
django/db/models/expressions.py
+3
-0
expressions.txt
docs/ref/models/expressions.txt
+7
-3
2.1.txt
docs/releases/2.1.txt
+2
-0
tests.py
tests/expressions/tests.py
+4
-0
No files found.
AUTHORS
Dosyayı görüntüle @
617d5f41
...
...
@@ -662,6 +662,7 @@ answer newbie questions, and generally made Django that much better:
pradeep.gowda@gmail.com
Preston Holmes <preston@ptone.com>
Preston Timmons <prestontimmons@gmail.com>
Priyansh Saxena <askpriyansh@gmail.com>
Rachel Tobin <rmtobin@me.com>
Rachel Willmer <http://www.willmer.com/kb/>
Radek Švarz <http://www.svarz.cz/translate/>
...
...
django/db/models/expressions.py
Dosyayı görüntüle @
617d5f41
...
...
@@ -65,6 +65,9 @@ class Combinable:
# OPERATORS #
#############
def
__neg__
(
self
):
return
self
.
_combine
(
-
1
,
self
.
MUL
,
False
)
def
__add__
(
self
,
other
):
return
self
.
_combine
(
other
,
self
.
ADD
,
False
)
...
...
docs/ref/models/expressions.txt
Dosyayı görüntüle @
617d5f41
...
...
@@ -13,9 +13,13 @@ more complex computations.
Supported arithmetic
====================
Django supports addition, subtraction, multiplication, division, modulo
arithmetic, and the power operator on query expressions, using Python constants,
variables, and even other expressions.
Django supports negation, addition, subtraction, multiplication, division,
modulo arithmetic, and the power operator on query expressions, using Python
constants, variables, and even other expressions.
.. versionchanged:: 2.1
Support for negation was added.
Some examples
=============
...
...
docs/releases/2.1.txt
Dosyayı görüntüle @
617d5f41
...
...
@@ -178,6 +178,8 @@ Models
:class:`~django.db.models.DateField` and
:class:`~django.db.models.DateTimeField` to the Monday of a week.
* Query expressions can now be negated using a minus sign.
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~
...
...
tests/expressions/tests.py
Dosyayı görüntüle @
617d5f41
...
...
@@ -1425,6 +1425,10 @@ class ReprTests(TestCase):
class
CombinableTests
(
SimpleTestCase
):
bitwise_msg
=
'Use .bitand() and .bitor() for bitwise logical operations.'
def
test_negation
(
self
):
c
=
Combinable
()
self
.
assertEqual
(
-
c
,
c
*
-
1
)
def
test_and
(
self
):
with
self
.
assertRaisesMessage
(
NotImplementedError
,
self
.
bitwise_msg
):
Combinable
()
&
Combinable
()
...
...
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