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
67d98441
Kaydet (Commit)
67d98441
authored
May 11, 2016
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #24227 -- Removed ManyToManyField special casing in model_to_dict().
üst
8f6a1a15
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
16 deletions
+5
-16
related.py
django/db/models/fields/related.py
+4
-1
models.py
django/forms/models.py
+1
-15
No files found.
django/db/models/fields/related.py
Dosyayı görüntüle @
67d98441
...
...
@@ -1565,7 +1565,10 @@ class ManyToManyField(RelatedField):
"""
Return the value of this field in the given model instance.
"""
return
getattr
(
obj
,
self
.
attname
)
.
all
()
qs
=
getattr
(
obj
,
self
.
attname
)
.
all
()
if
qs
.
_result_cache
is
not
None
:
return
[
item
.
pk
for
item
in
qs
]
return
list
(
qs
.
values_list
(
'pk'
,
flat
=
True
))
def
save_form_data
(
self
,
instance
,
data
):
getattr
(
instance
,
self
.
attname
)
.
set
(
data
)
...
...
django/forms/models.py
Dosyayı görüntüle @
67d98441
...
...
@@ -88,21 +88,7 @@ def model_to_dict(instance, fields=None, exclude=None):
continue
if
exclude
and
f
.
name
in
exclude
:
continue
if
f
.
many_to_many
:
# If the object doesn't have a primary key yet, just use an empty
# list for its m2m fields. Calling f.value_from_object will raise
# an exception.
if
instance
.
pk
is
None
:
data
[
f
.
name
]
=
[]
else
:
# MultipleChoiceWidget needs a list of pks, not object instances.
qs
=
f
.
value_from_object
(
instance
)
if
qs
.
_result_cache
is
not
None
:
data
[
f
.
name
]
=
[
item
.
pk
for
item
in
qs
]
else
:
data
[
f
.
name
]
=
list
(
qs
.
values_list
(
'pk'
,
flat
=
True
))
else
:
data
[
f
.
name
]
=
f
.
value_from_object
(
instance
)
data
[
f
.
name
]
=
f
.
value_from_object
(
instance
)
return
data
...
...
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