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
064d4b1c
Kaydet (Commit)
064d4b1c
authored
Agu 28, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25320 -- Reverted ManyToManyField.null to False for backwards compatibility.
Thanks Tom Christie for the report and review.
üst
4c30fa90
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
5 deletions
+26
-5
filters.py
django/contrib/admin/filters.py
+10
-2
related.py
django/db/models/fields/related.py
+0
-3
tests.py
tests/admin_filters/tests.py
+10
-0
test_field_flags.py
tests/model_fields/test_field_flags.py
+6
-0
No files found.
django/contrib/admin/filters.py
Dosyayı görüntüle @
064d4b1c
...
...
@@ -176,8 +176,16 @@ class RelatedFieldListFilter(FieldListFilter):
self
.
title
=
self
.
lookup_title
self
.
empty_value_display
=
model_admin
.
get_empty_value_display
()
@property
def
include_empty_choice
(
self
):
"""
Return True if a "(None)" choice should be included, which filters
out everything except empty relationships.
"""
return
self
.
field
.
null
or
(
self
.
field
.
is_relation
and
self
.
field
.
many_to_many
)
def
has_output
(
self
):
if
self
.
field
.
null
:
if
self
.
include_empty_choice
:
extra
=
1
else
:
extra
=
0
...
...
@@ -204,7 +212,7 @@ class RelatedFieldListFilter(FieldListFilter):
},
[
self
.
lookup_kwarg_isnull
]),
'display'
:
val
,
}
if
self
.
field
.
null
:
if
self
.
include_empty_choice
:
yield
{
'selected'
:
bool
(
self
.
lookup_val_isnull
),
'query_string'
:
cl
.
get_query_string
({
...
...
django/db/models/fields/related.py
Dosyayı görüntüle @
064d4b1c
...
...
@@ -2304,8 +2304,6 @@ class ManyToManyField(RelatedField):
self
.
db_table
=
db_table
self
.
swappable
=
swappable
# Many-to-many fields are always nullable.
self
.
null
=
True
def
check
(
self
,
**
kwargs
):
errors
=
super
(
ManyToManyField
,
self
)
.
check
(
**
kwargs
)
...
...
@@ -2552,7 +2550,6 @@ class ManyToManyField(RelatedField):
def
deconstruct
(
self
):
name
,
path
,
args
,
kwargs
=
super
(
ManyToManyField
,
self
)
.
deconstruct
()
# Handle the simpler arguments.
del
kwargs
[
"null"
]
if
self
.
db_table
is
not
None
:
kwargs
[
'db_table'
]
=
self
.
db_table
if
self
.
remote_field
.
db_constraint
is
not
True
:
...
...
tests/admin_filters/tests.py
Dosyayı görüntüle @
064d4b1c
...
...
@@ -523,6 +523,16 @@ class ListFiltersTests(TestCase):
self
.
assertEqual
(
choice
[
'selected'
],
True
)
self
.
assertEqual
(
choice
[
'query_string'
],
'?books_contributed__id__exact=
%
d'
%
self
.
django_book
.
pk
)
# With one book, the list filter should appear because there is also a
# (None) option.
Book
.
objects
.
exclude
(
pk
=
self
.
djangonaut_book
.
pk
)
.
delete
()
filterspec
=
changelist
.
get_filters
(
request
)[
0
]
self
.
assertEqual
(
len
(
filterspec
),
2
)
# With no books remaining, no list filters should appear.
Book
.
objects
.
all
()
.
delete
()
filterspec
=
changelist
.
get_filters
(
request
)[
0
]
self
.
assertEqual
(
len
(
filterspec
),
0
)
def
test_relatedonlyfieldlistfilter_foreignkey
(
self
):
modeladmin
=
BookAdminRelatedOnlyFilter
(
Book
,
site
)
...
...
tests/model_fields/test_field_flags.py
Dosyayı görüntüle @
064d4b1c
...
...
@@ -216,3 +216,9 @@ class FieldFlagsTests(test.SimpleTestCase):
reverse_field
=
field
.
remote_field
self
.
assertEqual
(
field
.
model
,
reverse_field
.
related_model
)
self
.
assertEqual
(
field
.
related_model
,
reverse_field
.
model
)
def
test_null
(
self
):
# null isn't well defined for a ManyToManyField, but changing it to
# True causes backwards compatibility problems (#25320).
self
.
assertFalse
(
AllFieldsModel
.
_meta
.
get_field
(
'm2m'
)
.
null
)
self
.
assertTrue
(
AllFieldsModel
.
_meta
.
get_field
(
'reverse2'
)
.
null
)
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