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
4bc00def
Kaydet (Commit)
4bc00def
authored
Agu 25, 2015
tarafından
sarthakmeh
Kaydeden (comit)
Tim Graham
Agu 25, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #14217 -- Added validation for field name collision when using model inheritance.
üst
7efdd404
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
AUTHORS
AUTHORS
+1
-0
base.py
django/db/models/base.py
+7
-1
test_models.py
tests/invalid_models_tests/test_models.py
+19
-0
No files found.
AUTHORS
Dosyayı görüntüle @
4bc00def
...
...
@@ -629,6 +629,7 @@ answer newbie questions, and generally made Django that much better:
Ryan Niemeyer <https://profiles.google.com/ryan.niemeyer/about>
Sam Newman <http://www.magpiebrain.com/>
Sander Dijkhuis <sander.dijkhuis@gmail.com>
Sarthak Mehrish <sarthakmeh03@gmail.com>
schwank@gmail.com
Scot Hacker <shacker@birdhouse.org>
Scott Barr <scott@divisionbyzero.com.au>
...
...
django/db/models/base.py
Dosyayı görüntüle @
4bc00def
...
...
@@ -1334,7 +1334,13 @@ class Model(six.with_metaclass(ModelBase)):
used_fields
[
f
.
attname
]
=
f
# Check that fields defined in the model don't clash with fields from
# parents.
# parents, including auto-generated fields like multi-table inheritance
# child accessors.
for
parent
in
cls
.
_meta
.
get_parent_list
():
for
f
in
parent
.
_meta
.
get_fields
():
if
f
not
in
used_fields
:
used_fields
[
f
.
name
]
=
f
for
f
in
cls
.
_meta
.
local_fields
:
clash
=
used_fields
.
get
(
f
.
name
)
or
used_fields
.
get
(
f
.
attname
)
or
None
# Note that we may detect clash between user-defined non-unique
...
...
tests/invalid_models_tests/test_models.py
Dosyayı görüntüle @
4bc00def
...
...
@@ -436,6 +436,25 @@ class FieldNamesTests(IsolatedModelsTestCase):
class
ShadowingFieldsTests
(
IsolatedModelsTestCase
):
def
test_field_name_clash_with_child_accessor
(
self
):
class
Parent
(
models
.
Model
):
pass
class
Child
(
Parent
):
child
=
models
.
CharField
(
max_length
=
100
)
errors
=
Child
.
check
()
expected
=
[
Error
(
"The field 'child' clashes with the field "
"'child' from model 'invalid_models_tests.parent'."
,
hint
=
None
,
obj
=
Child
.
_meta
.
get_field
(
'child'
),
id
=
'models.E006'
,
)
]
self
.
assertEqual
(
errors
,
expected
)
def
test_multiinheritance_clash
(
self
):
class
Mother
(
models
.
Model
):
clash
=
models
.
IntegerField
()
...
...
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