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
fbe89307
Kaydet (Commit)
fbe89307
authored
Eki 05, 2015
tarafından
Mariusz Felisiak
Kaydeden (comit)
Tim Graham
Eki 06, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[1.9.x] Fixed #25503 -- Fixed system check crash on ForeignKey to abstract model.
Backport of
914167ab
from master
üst
d81b0812
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
27 deletions
+38
-27
AUTHORS
AUTHORS
+1
-0
related.py
django/db/models/fields/related.py
+4
-1
1.8.6.txt
docs/releases/1.8.6.txt
+3
-0
test_relative_fields.py
tests/invalid_models_tests/test_relative_fields.py
+30
-26
No files found.
AUTHORS
Dosyayı görüntüle @
fbe89307
...
...
@@ -449,6 +449,7 @@ answer newbie questions, and generally made Django that much better:
Marian Andre <django@andre.sk>
Marijn Vriens <marijn@metronomo.cl>
Mario Gonzalez <gonzalemario@gmail.com>
Mariusz Felisiak <felisiak.mariusz@gmail.com>
Mark Biggers <biggers@utsl.com>
mark@junklight.com
Mark Lavin <markdlavin@gmail.com>
...
...
django/db/models/fields/related.py
Dosyayı görüntüle @
fbe89307
...
...
@@ -470,6 +470,9 @@ class ForeignObject(RelatedField):
except
exceptions
.
FieldDoesNotExist
:
return
[]
if
not
self
.
foreign_related_fields
:
return
[]
has_unique_field
=
any
(
rel_field
.
unique
for
rel_field
in
self
.
foreign_related_fields
)
if
not
has_unique_field
and
len
(
self
.
foreign_related_fields
)
>
1
:
...
...
@@ -572,7 +575,7 @@ class ForeignObject(RelatedField):
@property
def
foreign_related_fields
(
self
):
return
tuple
(
rhs_field
for
lhs_field
,
rhs_field
in
self
.
related_fields
)
return
tuple
(
rhs_field
for
lhs_field
,
rhs_field
in
self
.
related_fields
if
rhs_field
)
def
get_local_related_value
(
self
,
instance
):
return
self
.
get_instance_value_for_fields
(
instance
,
self
.
local_related_fields
)
...
...
docs/releases/1.8.6.txt
Dosyayı görüntüle @
fbe89307
...
...
@@ -14,3 +14,6 @@ Bugfixes
* Allowed "mode=memory" in SQLite test database name if supported
(:ticket:`12118`).
* Fixed system check crash on ``ForeignKey`` to abstract model
(:ticket:`25503`).
tests/invalid_models_tests/test_relative_fields.py
Dosyayı görüntüle @
fbe89307
...
...
@@ -386,25 +386,27 @@ class RelativeFieldTests(IsolatedModelsTestCase):
self
.
assertEqual
(
errors
,
expected
)
def
test_foreign_key_to_abstract_model
(
self
):
class
Model
(
models
.
Model
):
foreign_key
=
models
.
ForeignKey
(
'AbstractModel'
,
models
.
CASCADE
)
class
AbstractModel
(
models
.
Model
):
class
Meta
:
abstract
=
True
field
=
Model
.
_meta
.
get_field
(
'foreign_key'
)
errors
=
field
.
check
()
expected
=
[
Error
(
"Field defines a relation with model 'AbstractModel', "
"which is either not installed, or is abstract."
,
hint
=
None
,
obj
=
field
,
id
=
'fields.E300'
,
),
class
Model
(
models
.
Model
):
rel_string_foreign_key
=
models
.
ForeignKey
(
'AbstractModel'
,
models
.
CASCADE
)
rel_class_foreign_key
=
models
.
ForeignKey
(
AbstractModel
,
models
.
CASCADE
)
fields
=
[
Model
.
_meta
.
get_field
(
'rel_string_foreign_key'
),
Model
.
_meta
.
get_field
(
'rel_class_foreign_key'
),
]
self
.
assertEqual
(
errors
,
expected
)
expected_error
=
Error
(
"Field defines a relation with model 'AbstractModel', "
"which is either not installed, or is abstract."
,
id
=
'fields.E300'
,
)
for
field
in
fields
:
expected_error
.
obj
=
field
errors
=
field
.
check
()
self
.
assertEqual
(
errors
,
[
expected_error
])
def
test_m2m_to_abstract_model
(
self
):
class
AbstractModel
(
models
.
Model
):
...
...
@@ -412,20 +414,22 @@ class RelativeFieldTests(IsolatedModelsTestCase):
abstract
=
True
class
Model
(
models
.
Model
):
m2m
=
models
.
ManyToManyField
(
'AbstractModel'
)
rel_string_m2m
=
models
.
ManyToManyField
(
'AbstractModel'
)
rel_class_m2m
=
models
.
ManyToManyField
(
AbstractModel
)
field
=
Model
.
_meta
.
get_field
(
'm2m'
)
errors
=
field
.
check
(
from_model
=
Model
)
expected
=
[
Error
(
"Field defines a relation with model 'AbstractModel', "
"which is either not installed, or is abstract."
,
hint
=
None
,
obj
=
field
,
id
=
'fields.E300'
,
),
fields
=
[
Model
.
_meta
.
get_field
(
'rel_string_m2m'
),
Model
.
_meta
.
get_field
(
'rel_class_m2m'
),
]
self
.
assertEqual
(
errors
,
expected
)
expected_error
=
Error
(
"Field defines a relation with model 'AbstractModel', "
"which is either not installed, or is abstract."
,
id
=
'fields.E300'
,
)
for
field
in
fields
:
expected_error
.
obj
=
field
errors
=
field
.
check
(
from_model
=
Model
)
self
.
assertEqual
(
errors
,
[
expected_error
])
def
test_unique_m2m
(
self
):
class
Person
(
models
.
Model
):
...
...
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