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
d731f48e
Kaydet (Commit)
d731f48e
authored
May 21, 2014
tarafından
Ramiro Morales
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #2679 from ramiro/t22421
Fixed #22421 -- Regression in fixtures loading.
üst
64ee097b
862e1ff2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
3 deletions
+45
-3
related.py
django/db/models/fields/related.py
+4
-2
feature.json
tests/fixtures_regress/fixtures/feature.json
+17
-0
models.py
tests/fixtures_regress/models.py
+12
-1
tests.py
tests/fixtures_regress/tests.py
+12
-0
No files found.
django/db/models/fields/related.py
Dosyayı görüntüle @
d731f48e
...
...
@@ -1440,14 +1440,16 @@ class ForeignObject(RelatedField):
@staticmethod
def
get_instance_value_for_fields
(
instance
,
fields
):
ret
=
[]
opts
=
instance
.
_meta
for
field
in
fields
:
# Gotcha: in some cases (like fixture loading) a model can have
# different values in parent_ptr_id and parent's id. So, use
# instance.pk (that is, parent_ptr_id) when asked for instance.id.
opts
=
instance
.
_meta
if
field
.
primary_key
:
possible_parent_link
=
opts
.
get_ancestor_link
(
field
.
model
)
if
not
possible_parent_link
or
possible_parent_link
.
primary_key
:
if
(
not
possible_parent_link
or
possible_parent_link
.
primary_key
or
possible_parent_link
.
model
.
_meta
.
abstract
):
ret
.
append
(
instance
.
pk
)
continue
ret
.
append
(
getattr
(
instance
,
field
.
attname
))
...
...
tests/fixtures_regress/fixtures/feature.json
0 → 100644
Dosyayı görüntüle @
d731f48e
[
{
"fields"
:
{
"channels"
:
[],
"title"
:
"Title of this feature article"
},
"model"
:
"fixtures_regress.article"
,
"pk"
:
1
},
{
"fields"
:
{
"channels"
:
[]
},
"model"
:
"fixtures_regress.feature"
,
"pk"
:
1
}
]
tests/fixtures_regress/models.py
Dosyayı görüntüle @
d731f48e
...
...
@@ -52,7 +52,7 @@ class Child(Parent):
data
=
models
.
CharField
(
max_length
=
10
)
# Models to regression test #7572
# Models to regression test #7572
, #20820
class
Channel
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
255
)
...
...
@@ -70,6 +70,17 @@ class SpecialArticle(Article):
pass
# Models to regression test #22421
class
CommonFeature
(
Article
):
class
Meta
:
abstract
=
True
class
Feature
(
CommonFeature
):
pass
# Models to regression test #11428
@python_2_unicode_compatible
class
Widget
(
models
.
Model
):
...
...
tests/fixtures_regress/tests.py
Dosyayı görüntüle @
d731f48e
...
...
@@ -486,6 +486,18 @@ class TestFixtures(TestCase):
verbosity
=
0
,
)
def
test_ticket_22421
(
self
):
"""
Regression for ticket #22421 -- loaddata on a model that inherits from
a grand-parent model with a M2M but via an abstract parent shouldn't
blow up.
"""
management
.
call_command
(
'loaddata'
,
'feature.json'
,
verbosity
=
0
,
)
class
NaturalKeyFixtureTests
(
TestCase
):
...
...
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