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
4b9fa49b
Kaydet (Commit)
4b9fa49b
authored
Şub 19, 2013
tarafından
Anssi Kääriäinen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Avoided related_name conflicts in tests
üst
607772b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
models.py
tests/regressiontests/aggregation_regress/models.py
+2
-2
tests.py
tests/regressiontests/aggregation_regress/tests.py
+5
-5
No files found.
tests/regressiontests/aggregation_regress/models.py
Dosyayı görüntüle @
4b9fa49b
...
@@ -24,7 +24,7 @@ class Publisher(models.Model):
...
@@ -24,7 +24,7 @@ class Publisher(models.Model):
return
self
.
name
return
self
.
name
class
TaggedItem
(
models
.
Model
):
class
ItemTag
(
models
.
Model
):
tag
=
models
.
CharField
(
max_length
=
100
)
tag
=
models
.
CharField
(
max_length
=
100
)
content_type
=
models
.
ForeignKey
(
ContentType
)
content_type
=
models
.
ForeignKey
(
ContentType
)
object_id
=
models
.
PositiveIntegerField
()
object_id
=
models
.
PositiveIntegerField
()
...
@@ -42,7 +42,7 @@ class Book(models.Model):
...
@@ -42,7 +42,7 @@ class Book(models.Model):
contact
=
models
.
ForeignKey
(
Author
,
related_name
=
'book_contact_set'
)
contact
=
models
.
ForeignKey
(
Author
,
related_name
=
'book_contact_set'
)
publisher
=
models
.
ForeignKey
(
Publisher
)
publisher
=
models
.
ForeignKey
(
Publisher
)
pubdate
=
models
.
DateField
()
pubdate
=
models
.
DateField
()
tags
=
generic
.
GenericRelation
(
TaggedItem
)
tags
=
generic
.
GenericRelation
(
ItemTag
)
class
Meta
:
class
Meta
:
ordering
=
(
'name'
,)
ordering
=
(
'name'
,)
...
...
tests/regressiontests/aggregation_regress/tests.py
Dosyayı görüntüle @
4b9fa49b
...
@@ -12,7 +12,7 @@ from django.test import TestCase, Approximate, skipUnlessDBFeature
...
@@ -12,7 +12,7 @@ from django.test import TestCase, Approximate, skipUnlessDBFeature
from
django.utils
import
six
from
django.utils
import
six
from
.models
import
(
Author
,
Book
,
Publisher
,
Clues
,
Entries
,
HardbackBook
,
from
.models
import
(
Author
,
Book
,
Publisher
,
Clues
,
Entries
,
HardbackBook
,
TaggedItem
,
WithManualPK
)
ItemTag
,
WithManualPK
)
class
AggregationTests
(
TestCase
):
class
AggregationTests
(
TestCase
):
...
@@ -993,18 +993,18 @@ class AggregationTests(TestCase):
...
@@ -993,18 +993,18 @@ class AggregationTests(TestCase):
tests aggregations with generic reverse relations
tests aggregations with generic reverse relations
"""
"""
b
=
Book
.
objects
.
get
(
name
=
'Practical Django Projects'
)
b
=
Book
.
objects
.
get
(
name
=
'Practical Django Projects'
)
TaggedItem
.
objects
.
create
(
object_id
=
b
.
id
,
tag
=
'intermediate'
,
ItemTag
.
objects
.
create
(
object_id
=
b
.
id
,
tag
=
'intermediate'
,
content_type
=
ContentType
.
objects
.
get_for_model
(
b
))
content_type
=
ContentType
.
objects
.
get_for_model
(
b
))
TaggedItem
.
objects
.
create
(
object_id
=
b
.
id
,
tag
=
'django'
,
ItemTag
.
objects
.
create
(
object_id
=
b
.
id
,
tag
=
'django'
,
content_type
=
ContentType
.
objects
.
get_for_model
(
b
))
content_type
=
ContentType
.
objects
.
get_for_model
(
b
))
# Assign a tag to model with same PK as the book above. If the JOIN
# Assign a tag to model with same PK as the book above. If the JOIN
# used in aggregation doesn't have content type as part of the
# used in aggregation doesn't have content type as part of the
# condition the annotation will also count the 'hi mom' tag for b.
# condition the annotation will also count the 'hi mom' tag for b.
wmpk
=
WithManualPK
.
objects
.
create
(
id
=
b
.
pk
)
wmpk
=
WithManualPK
.
objects
.
create
(
id
=
b
.
pk
)
TaggedItem
.
objects
.
create
(
object_id
=
wmpk
.
id
,
tag
=
'hi mom'
,
ItemTag
.
objects
.
create
(
object_id
=
wmpk
.
id
,
tag
=
'hi mom'
,
content_type
=
ContentType
.
objects
.
get_for_model
(
wmpk
))
content_type
=
ContentType
.
objects
.
get_for_model
(
wmpk
))
b
=
Book
.
objects
.
get
(
name__startswith
=
'Paradigms of Artificial Intelligence'
)
b
=
Book
.
objects
.
get
(
name__startswith
=
'Paradigms of Artificial Intelligence'
)
TaggedItem
.
objects
.
create
(
object_id
=
b
.
id
,
tag
=
'intermediate'
,
ItemTag
.
objects
.
create
(
object_id
=
b
.
id
,
tag
=
'intermediate'
,
content_type
=
ContentType
.
objects
.
get_for_model
(
b
))
content_type
=
ContentType
.
objects
.
get_for_model
(
b
))
self
.
assertEqual
(
Book
.
objects
.
aggregate
(
Count
(
'tags'
)),
{
'tags__count'
:
3
})
self
.
assertEqual
(
Book
.
objects
.
aggregate
(
Count
(
'tags'
)),
{
'tags__count'
:
3
})
...
...
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