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
c6c00fbf
Kaydet (Commit)
c6c00fbf
authored
Agu 04, 2015
tarafından
Curtis Maloney
Kaydeden (comit)
Tim Graham
Agu 04, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Used @cached_property for BaseForm.changed_data.
üst
9f73009e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
24 deletions
+23
-24
forms.py
django/forms/forms.py
+23
-24
No files found.
django/forms/forms.py
Dosyayı görüntüle @
c6c00fbf
...
@@ -16,6 +16,7 @@ from django.utils import six
...
@@ -16,6 +16,7 @@ from django.utils import six
from
django.utils.encoding
import
(
from
django.utils.encoding
import
(
force_text
,
python_2_unicode_compatible
,
smart_text
,
force_text
,
python_2_unicode_compatible
,
smart_text
,
)
)
from
django.utils.functional
import
cached_property
from
django.utils.html
import
conditional_escape
,
format_html
,
html_safe
from
django.utils.html
import
conditional_escape
,
format_html
,
html_safe
from
django.utils.safestring
import
mark_safe
from
django.utils.safestring
import
mark_safe
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
...
@@ -92,7 +93,6 @@ class BaseForm(object):
...
@@ -92,7 +93,6 @@ class BaseForm(object):
self
.
label_suffix
=
label_suffix
if
label_suffix
is
not
None
else
_
(
':'
)
self
.
label_suffix
=
label_suffix
if
label_suffix
is
not
None
else
_
(
':'
)
self
.
empty_permitted
=
empty_permitted
self
.
empty_permitted
=
empty_permitted
self
.
_errors
=
None
# Stores the errors after clean() has been called.
self
.
_errors
=
None
# Stores the errors after clean() has been called.
self
.
_changed_data
=
None
# The base_fields class attribute is the *class-wide* definition of
# The base_fields class attribute is the *class-wide* definition of
# fields. Because a particular *instance* of the class might want to
# fields. Because a particular *instance* of the class might want to
...
@@ -434,30 +434,29 @@ class BaseForm(object):
...
@@ -434,30 +434,29 @@ class BaseForm(object):
"""
"""
return
bool
(
self
.
changed_data
)
return
bool
(
self
.
changed_data
)
@property
@
cached_
property
def
changed_data
(
self
):
def
changed_data
(
self
):
if
self
.
_changed_data
is
None
:
data
=
[]
self
.
_changed_data
=
[]
for
name
,
field
in
self
.
fields
.
items
():
for
name
,
field
in
self
.
fields
.
items
():
prefixed_name
=
self
.
add_prefix
(
name
)
prefixed_name
=
self
.
add_prefix
(
name
)
data_value
=
field
.
widget
.
value_from_datadict
(
self
.
data
,
self
.
files
,
prefixed_name
)
data_value
=
field
.
widget
.
value_from_datadict
(
self
.
data
,
self
.
files
,
prefixed_name
)
if
not
field
.
show_hidden_initial
:
if
not
field
.
show_hidden_initial
:
initial_value
=
self
.
initial
.
get
(
name
,
field
.
initial
)
initial_value
=
self
.
initial
.
get
(
name
,
field
.
initial
)
if
callable
(
initial_value
):
if
callable
(
initial_value
):
initial_value
=
initial_value
()
initial_value
=
initial_value
()
else
:
else
:
initial_prefixed_name
=
self
.
add_initial_prefix
(
name
)
initial_prefixed_name
=
self
.
add_initial_prefix
(
name
)
hidden_widget
=
field
.
hidden_widget
()
hidden_widget
=
field
.
hidden_widget
()
try
:
try
:
initial_value
=
field
.
to_python
(
hidden_widget
.
value_from_datadict
(
initial_value
=
field
.
to_python
(
hidden_widget
.
value_from_datadict
(
self
.
data
,
self
.
files
,
initial_prefixed_name
))
self
.
data
,
self
.
files
,
initial_prefixed_name
))
except
ValidationError
:
except
ValidationError
:
# Always assume data has changed if validation fails.
# Always assume data has changed if validation fails.
data
.
append
(
name
)
self
.
_changed_data
.
append
(
name
)
continue
continue
if
field
.
has_changed
(
initial_value
,
data_value
):
if
field
.
has_changed
(
initial_value
,
data_value
):
data
.
append
(
name
)
self
.
_changed_data
.
append
(
name
)
return
data
return
self
.
_changed_data
@property
@property
def
media
(
self
):
def
media
(
self
):
...
...
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