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
92476e88
Kaydet (Commit)
92476e88
authored
Tem 25, 2013
tarafından
Anssi Kääriäinen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed ._meta.pk_index() virtual field failure
üst
dab52d99
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
options.py
django/db/models/options.py
+3
-2
models.py
tests/foreign_object/models.py
+3
-0
tests.py
tests/foreign_object/tests.py
+17
-1
No files found.
django/db/models/options.py
Dosyayı görüntüle @
92476e88
...
...
@@ -204,9 +204,10 @@ class Options(object):
def
pk_index
(
self
):
"""
Returns the index of the primary key field in the self.fields list.
Returns the index of the primary key field in the self.concrete_fields
list.
"""
return
self
.
fields
.
index
(
self
.
pk
)
return
self
.
concrete_
fields
.
index
(
self
.
pk
)
def
setup_proxy
(
self
,
target
):
"""
...
...
tests/foreign_object/models.py
Dosyayı görüntüle @
92476e88
...
...
@@ -140,6 +140,9 @@ class Article(models.Model):
except
ArticleTranslation
.
DoesNotExist
:
return
'[No translation found]'
class
NewsArticle
(
Article
):
pass
class
ArticleTranslation
(
models
.
Model
):
article
=
models
.
ForeignKey
(
Article
)
lang
=
models
.
CharField
(
max_length
=
'2'
)
...
...
tests/foreign_object/tests.py
Dosyayı görüntüle @
92476e88
import
datetime
from
operator
import
attrgetter
from
.models
import
Country
,
Person
,
Group
,
Membership
,
Friendship
,
Article
,
ArticleTranslation
,
ArticleTag
,
ArticleIdea
from
.models
import
(
Country
,
Person
,
Group
,
Membership
,
Friendship
,
Article
,
ArticleTranslation
,
ArticleTag
,
ArticleIdea
,
NewsArticle
)
from
django.test
import
TestCase
from
django.utils.translation
import
activate
from
django.core.exceptions
import
FieldError
...
...
@@ -339,6 +341,20 @@ class MultiColumnFKTests(TestCase):
with
self
.
assertRaises
(
FieldError
):
Article
.
objects
.
filter
(
ideas__name
=
"idea1"
)
def
test_inheritance
(
self
):
activate
(
"fi"
)
na
=
NewsArticle
.
objects
.
create
(
pub_date
=
datetime
.
date
.
today
())
ArticleTranslation
.
objects
.
create
(
article
=
na
,
lang
=
"fi"
,
title
=
"foo"
,
body
=
"bar"
)
self
.
assertQuerysetEqual
(
NewsArticle
.
objects
.
select_related
(
'active_translation'
),
[
na
],
lambda
x
:
x
)
with
self
.
assertNumQueries
(
1
):
self
.
assertEqual
(
NewsArticle
.
objects
.
select_related
(
'active_translation'
)[
0
]
.
active_translation
.
title
,
"foo"
)
class
FormsTests
(
TestCase
):
# ForeignObjects should not have any form fields, currently the user needs
...
...
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