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
58c7ff39
Kaydet (Commit)
58c7ff39
authored
Eki 02, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #13203, #9501 -- Added a test for generic relations to child models.
Fixed in
97774429
.
üst
ac09d22f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
models.py
tests/generic_relations/models.py
+4
-0
tests.py
tests/generic_relations/tests.py
+9
-1
No files found.
tests/generic_relations/models.py
Dosyayı görüntüle @
58c7ff39
...
@@ -114,6 +114,10 @@ class Rock(Mineral):
...
@@ -114,6 +114,10 @@ class Rock(Mineral):
tags
=
GenericRelation
(
TaggedItem
)
tags
=
GenericRelation
(
TaggedItem
)
class
ValuableRock
(
Mineral
):
tags
=
GenericRelation
(
ValuableTaggedItem
)
class
ManualPK
(
models
.
Model
):
class
ManualPK
(
models
.
Model
):
id
=
models
.
IntegerField
(
primary_key
=
True
)
id
=
models
.
IntegerField
(
primary_key
=
True
)
tags
=
GenericRelation
(
TaggedItem
,
related_query_name
=
'manualpk'
)
tags
=
GenericRelation
(
TaggedItem
,
related_query_name
=
'manualpk'
)
...
...
tests/generic_relations/tests.py
Dosyayı görüntüle @
58c7ff39
...
@@ -12,7 +12,8 @@ from django.utils import six
...
@@ -12,7 +12,8 @@ from django.utils import six
from
.models
import
(
from
.models
import
(
AllowsNullGFK
,
Animal
,
Comparison
,
ConcreteRelatedModel
,
AllowsNullGFK
,
Animal
,
Comparison
,
ConcreteRelatedModel
,
ForConcreteModelModel
,
ForProxyModelModel
,
Gecko
,
ManualPK
,
Mineral
,
ForConcreteModelModel
,
ForProxyModelModel
,
Gecko
,
ManualPK
,
Mineral
,
ProxyRelatedModel
,
Rock
,
TaggedItem
,
ValuableTaggedItem
,
Vegetable
,
ProxyRelatedModel
,
Rock
,
TaggedItem
,
ValuableRock
,
ValuableTaggedItem
,
Vegetable
,
)
)
...
@@ -400,6 +401,13 @@ class GenericRelationsTests(TestCase):
...
@@ -400,6 +401,13 @@ class GenericRelationsTests(TestCase):
)
)
self
.
assertEqual
(
valuedtag
.
content_object
,
quartz
)
self
.
assertEqual
(
valuedtag
.
content_object
,
quartz
)
def
test_generic_relation_to_inherited_child
(
self
):
# GenericRelations to models that use multi-table inheritance work.
granite
=
ValuableRock
.
objects
.
create
(
name
=
'granite'
,
hardness
=
5
)
ValuableTaggedItem
.
objects
.
create
(
content_object
=
granite
,
tag
=
"countertop"
,
value
=
1
)
granite
.
delete
()
# deleting the rock should delete the related tag.
self
.
assertEqual
(
ValuableTaggedItem
.
objects
.
count
(),
0
)
def
test_generic_inline_formsets
(
self
):
def
test_generic_inline_formsets
(
self
):
GenericFormSet
=
generic_inlineformset_factory
(
TaggedItem
,
extra
=
1
)
GenericFormSet
=
generic_inlineformset_factory
(
TaggedItem
,
extra
=
1
)
formset
=
GenericFormSet
()
formset
=
GenericFormSet
()
...
...
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