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
ee596888
Kaydet (Commit)
ee596888
authored
Ock 20, 2016
tarafından
Anssi Kääriäinen
Kaydeden (comit)
Tim Graham
Ock 21, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26092 -- Fixed QuerySet.order_by() regression with an M2M through model.
üst
2d28144c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
1 deletion
+19
-1
compiler.py
django/db/models/sql/compiler.py
+1
-1
1.9.2.txt
docs/releases/1.9.2.txt
+3
-0
models.py
tests/m2m_through/models.py
+1
-0
tests.py
tests/m2m_through/tests.py
+14
-0
No files found.
django/db/models/sql/compiler.py
Dosyayı görüntüle @
ee596888
...
@@ -555,7 +555,7 @@ class SQLCompiler(object):
...
@@ -555,7 +555,7 @@ class SQLCompiler(object):
# If we get to this point and the field is a relation to another model,
# If we get to this point and the field is a relation to another model,
# append the default ordering for that model unless the attribute name
# append the default ordering for that model unless the attribute name
# of the field is specified.
# of the field is specified.
if
field
.
is_relation
and
path
and
opts
.
ordering
and
name
!=
field
.
att
name
:
if
field
.
is_relation
and
opts
.
ordering
and
getattr
(
field
,
'attname'
,
None
)
!=
name
:
# Firstly, avoid infinite loops.
# Firstly, avoid infinite loops.
if
not
already_seen
:
if
not
already_seen
:
already_seen
=
set
()
already_seen
=
set
()
...
...
docs/releases/1.9.2.txt
Dosyayı görüntüle @
ee596888
...
@@ -41,3 +41,6 @@ Bugfixes
...
@@ -41,3 +41,6 @@ Bugfixes
* Fixed CSRF cookie check on POST requests when ``USE_X_FORWARDED_PORT=True``
* Fixed CSRF cookie check on POST requests when ``USE_X_FORWARDED_PORT=True``
(:ticket:`26094`).
(:ticket:`26094`).
* Fixed a ``QuerySet.order_by()`` crash when ordering by a relational field of
a ``ManyToManyField`` ``through`` model (:ticket:`26092`).
tests/m2m_through/models.py
Dosyayı görüntüle @
ee596888
...
@@ -65,6 +65,7 @@ class CustomMembership(models.Model):
...
@@ -65,6 +65,7 @@ class CustomMembership(models.Model):
class
Meta
:
class
Meta
:
db_table
=
"test_table"
db_table
=
"test_table"
ordering
=
[
"date_joined"
]
class
TestNoDefaultsOrNulls
(
models
.
Model
):
class
TestNoDefaultsOrNulls
(
models
.
Model
):
...
...
tests/m2m_through/tests.py
Dosyayı görüntüle @
ee596888
...
@@ -198,6 +198,20 @@ class M2mThroughTests(TestCase):
...
@@ -198,6 +198,20 @@ class M2mThroughTests(TestCase):
attrgetter
(
"name"
)
attrgetter
(
"name"
)
)
)
def
test_order_by_relational_field_through_model
(
self
):
CustomMembership
.
objects
.
create
(
person
=
self
.
jim
,
group
=
self
.
rock
)
CustomMembership
.
objects
.
create
(
person
=
self
.
bob
,
group
=
self
.
rock
)
CustomMembership
.
objects
.
create
(
person
=
self
.
jane
,
group
=
self
.
roll
)
CustomMembership
.
objects
.
create
(
person
=
self
.
jim
,
group
=
self
.
roll
)
self
.
assertQuerysetEqual
(
self
.
rock
.
custom_members
.
order_by
(
'custom_person_related_name'
),
[
self
.
jim
,
self
.
bob
],
lambda
x
:
x
)
self
.
assertQuerysetEqual
(
self
.
roll
.
custom_members
.
order_by
(
'custom_person_related_name'
),
[
self
.
jane
,
self
.
jim
],
lambda
x
:
x
)
def
test_query_first_model_by_intermediate_model_attribute
(
self
):
def
test_query_first_model_by_intermediate_model_attribute
(
self
):
Membership
.
objects
.
create
(
Membership
.
objects
.
create
(
person
=
self
.
jane
,
group
=
self
.
roll
,
person
=
self
.
jane
,
group
=
self
.
roll
,
...
...
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