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
4a7b5821
Kaydet (Commit)
4a7b5821
authored
Eki 08, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #19722 -- Added a test for querying generic relations of a parent class.
Fixed in
c9a96075
.
üst
25f287f6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
models.py
tests/generic_relations/models.py
+4
-0
tests.py
tests/generic_relations/tests.py
+11
-2
No files found.
tests/generic_relations/models.py
Dosyayı görüntüle @
4a7b5821
...
@@ -88,6 +88,10 @@ class Vegetable(models.Model):
...
@@ -88,6 +88,10 @@ class Vegetable(models.Model):
return
self
.
name
return
self
.
name
class
Carrot
(
Vegetable
):
pass
@python_2_unicode_compatible
@python_2_unicode_compatible
class
Mineral
(
models
.
Model
):
class
Mineral
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
150
)
name
=
models
.
CharField
(
max_length
=
150
)
...
...
tests/generic_relations/tests.py
Dosyayı görüntüle @
4a7b5821
...
@@ -10,7 +10,7 @@ from django.test import SimpleTestCase, TestCase
...
@@ -10,7 +10,7 @@ from django.test import SimpleTestCase, TestCase
from
django.utils
import
six
from
django.utils
import
six
from
.models
import
(
from
.models
import
(
AllowsNullGFK
,
Animal
,
Comparison
,
ConcreteRelatedModel
,
AllowsNullGFK
,
Animal
,
C
arrot
,
C
omparison
,
ConcreteRelatedModel
,
ForConcreteModelModel
,
ForProxyModelModel
,
Gecko
,
ManualPK
,
Mineral
,
ForConcreteModelModel
,
ForProxyModelModel
,
Gecko
,
ManualPK
,
Mineral
,
ProxyRelatedModel
,
Rock
,
TaggedItem
,
ValuableRock
,
ValuableTaggedItem
,
ProxyRelatedModel
,
Rock
,
TaggedItem
,
ValuableRock
,
ValuableTaggedItem
,
Vegetable
,
Vegetable
,
...
@@ -488,7 +488,16 @@ id="id_generic_relations-taggeditem-content_type-object_id-1-id" /></p>""" % tag
...
@@ -488,7 +488,16 @@ id="id_generic_relations-taggeditem-content_type-object_id-1-id" /></p>""" % tag
"""
"""
granite
=
Rock
.
objects
.
create
(
name
=
'granite'
,
hardness
=
5
)
granite
=
Rock
.
objects
.
create
(
name
=
'granite'
,
hardness
=
5
)
TaggedItem
.
objects
.
create
(
content_object
=
granite
,
tag
=
"countertop"
)
TaggedItem
.
objects
.
create
(
content_object
=
granite
,
tag
=
"countertop"
)
self
.
assertEqual
(
Rock
.
objects
.
filter
(
tags__tag
=
"countertop"
)
.
count
(),
1
)
self
.
assertEqual
(
Rock
.
objects
.
get
(
tags__tag
=
"countertop"
),
granite
)
def
test_subclasses_with_parent_gen_rel
(
self
):
"""
Generic relations on a base class (Vegetable) work correctly in
subclasses (Carrot).
"""
bear
=
Carrot
.
objects
.
create
(
name
=
'carrot'
)
TaggedItem
.
objects
.
create
(
content_object
=
bear
,
tag
=
'orange'
)
self
.
assertEqual
(
Carrot
.
objects
.
get
(
tags__tag
=
'orange'
),
bear
)
def
test_generic_inline_formsets_initial
(
self
):
def
test_generic_inline_formsets_initial
(
self
):
"""
"""
...
...
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