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
0c3c37a3
Kaydet (Commit)
0c3c37a3
authored
Haz 07, 2017
tarafından
Jon Dufresne
Kaydeden (comit)
Tim Graham
Haz 08, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28282 -- Fixed class-based indexes name for models that only inherit Model.
üst
085c2f94
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
8 deletions
+19
-8
base.py
django/db/models/base.py
+9
-8
1.11.3.txt
docs/releases/1.11.3.txt
+3
-0
models.py
tests/model_indexes/models.py
+3
-0
tests.py
tests/model_indexes/tests.py
+4
-0
No files found.
django/db/models/base.py
Dosyayı görüntüle @
0c3c37a3
...
...
@@ -293,14 +293,15 @@ class ModelBase(type):
else
:
new_class
.
add_to_class
(
field
.
name
,
copy
.
deepcopy
(
field
))
if
base_meta
and
base_meta
.
abstract
and
not
abstract
:
new_class
.
_meta
.
indexes
=
[
copy
.
deepcopy
(
idx
)
for
idx
in
new_class
.
_meta
.
indexes
]
# Set the name of _meta.indexes. This can't be done in
# Options.contribute_to_class() because fields haven't been added
# to the model at that point.
for
index
in
new_class
.
_meta
.
indexes
:
if
not
index
.
name
:
index
.
set_name_with_model
(
new_class
)
# Copy indexes so that index names are unique when models extend an
# abstract model.
new_class
.
_meta
.
indexes
=
[
copy
.
deepcopy
(
idx
)
for
idx
in
new_class
.
_meta
.
indexes
]
# Set the name of _meta.indexes. This can't be done in
# Options.contribute_to_class() because fields haven't been added to
# the model at that point.
for
index
in
new_class
.
_meta
.
indexes
:
if
not
index
.
name
:
index
.
set_name_with_model
(
new_class
)
if
abstract
:
# Abstract base models can't be instantiated and don't appear in
...
...
docs/releases/1.11.3.txt
Dosyayı görüntüle @
0c3c37a3
...
...
@@ -23,3 +23,6 @@ Bugfixes
(:ticket:`28202`).
* Fixed invalid HTML for a required ``AdminFileWidget`` (:ticket:`28278`).
* Fixed model initialization to set the name of class-based model indexes
for models that only inherit ``models.Model`` (:ticket:`28282`).
tests/model_indexes/models.py
Dosyayı görüntüle @
0c3c37a3
...
...
@@ -6,6 +6,9 @@ class Book(models.Model):
author
=
models
.
CharField
(
max_length
=
50
)
pages
=
models
.
IntegerField
(
db_column
=
'page_count'
)
class
Meta
:
indexes
=
[
models
.
indexes
.
Index
(
fields
=
[
'title'
])]
class
AbstractModel
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
...
...
tests/model_indexes/tests.py
Dosyayı görüntüle @
0c3c37a3
...
...
@@ -83,6 +83,10 @@ class IndexesTests(SimpleTestCase):
self
.
assertIsNot
(
index
,
new_index
)
self
.
assertEqual
(
index
.
fields
,
new_index
.
fields
)
def
test_name_set
(
self
):
index_names
=
[
index
.
name
for
index
in
Book
.
_meta
.
indexes
]
self
.
assertEqual
(
index_names
,
[
'model_index_title_196f42_idx'
])
def
test_abstract_children
(
self
):
index_names
=
[
index
.
name
for
index
in
ChildModel1
.
_meta
.
indexes
]
self
.
assertEqual
(
index_names
,
[
'model_index_name_440998_idx'
])
...
...
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