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
a4055adf
Kaydet (Commit)
a4055adf
authored
Nis 16, 2019
tarafından
Vinny Do
Kaydeden (comit)
Mariusz Felisiak
Nis 16, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #30368 -- Fixed prefetch_related() for GenericForeignKey when PK is also a FK.
üst
d610521b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
0 deletions
+11
-0
AUTHORS
AUTHORS
+1
-0
related.py
django/db/models/fields/related.py
+3
-0
tests.py
tests/prefetch_related/tests.py
+7
-0
No files found.
AUTHORS
Dosyayı görüntüle @
a4055adf
...
...
@@ -880,6 +880,7 @@ answer newbie questions, and generally made Django that much better:
Vinay Karanam <https://github.com/vinayinvicible>
Vinay Sajip <vinay_sajip@yahoo.co.uk>
Vincent Foley <vfoleybourgon@yahoo.ca>
Vinny Do <vdo.code@gmail.com>
Vitaly Babiy <vbabiy86@gmail.com>
Vladimir Kuzma <vladimirkuzma.ch@gmail.com>
Vlado <vlado@labath.org>
...
...
django/db/models/fields/related.py
Dosyayı görüntüle @
a4055adf
...
...
@@ -939,6 +939,9 @@ class ForeignKey(ForeignObject):
def
get_db_prep_value
(
self
,
value
,
connection
,
prepared
=
False
):
return
self
.
target_field
.
get_db_prep_value
(
value
,
connection
,
prepared
)
def
get_prep_value
(
self
,
value
):
return
self
.
target_field
.
get_prep_value
(
value
)
def
contribute_to_related_class
(
self
,
cls
,
related
):
super
()
.
contribute_to_related_class
(
cls
,
related
)
if
self
.
remote_field
.
field_name
is
None
:
...
...
tests/prefetch_related/tests.py
Dosyayı görüntüle @
a4055adf
...
...
@@ -891,6 +891,13 @@ class GenericRelationTests(TestCase):
qs
=
Comment
.
objects
.
prefetch_related
(
'content_object_uuid'
)
self
.
assertEqual
([
c
.
content_object_uuid
for
c
in
qs
],
[
article
])
def
test_prefetch_GFK_fk_pk
(
self
):
book
=
Book
.
objects
.
create
(
title
=
'Poems'
)
book_with_year
=
BookWithYear
.
objects
.
create
(
book
=
book
,
published_year
=
2019
)
Comment
.
objects
.
create
(
comment
=
'awesome'
,
content_object
=
book_with_year
)
qs
=
Comment
.
objects
.
prefetch_related
(
'content_object'
)
self
.
assertEqual
([
c
.
content_object
for
c
in
qs
],
[
book_with_year
])
def
test_traverse_GFK
(
self
):
"""
A 'content_object' can be traversed with prefetch_related() and
...
...
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