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
859eeaa0
Kaydet (Commit)
859eeaa0
authored
Nis 23, 2016
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26533 -- Renamed Widget._format_value() to format_value().
üst
669c29c8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
9 deletions
+35
-9
widgets.py
django/contrib/admin/widgets.py
+1
-1
widgets.py
django/forms/widgets.py
+13
-4
deprecation.txt
docs/internals/deprecation.txt
+2
-0
widgets.txt
docs/ref/forms/widgets.txt
+11
-0
1.10.txt
docs/releases/1.10.txt
+4
-0
test_datefield.py
tests/forms_tests/field_tests/test_datefield.py
+4
-4
test_input_formats.py
tests/forms_tests/tests/test_input_formats.py
+0
-0
No files found.
django/contrib/admin/widgets.py
Dosyayı görüntüle @
859eeaa0
...
...
@@ -376,7 +376,7 @@ class AdminURLFieldWidget(forms.URLInput):
def
render
(
self
,
name
,
value
,
attrs
=
None
):
html
=
super
(
AdminURLFieldWidget
,
self
)
.
render
(
name
,
value
,
attrs
)
if
value
:
value
=
force_text
(
self
.
_
format_value
(
value
))
value
=
force_text
(
self
.
format_value
(
value
))
final_attrs
=
{
'href'
:
smart_urlquote
(
value
)}
html
=
format_html
(
'<p class="url">{} <a{}>{}</a><br />{} {}</p>'
,
...
...
django/forms/widgets.py
Dosyayı görüntüle @
859eeaa0
...
...
@@ -15,6 +15,9 @@ from django.templatetags.static import static
from
django.utils
import
datetime_safe
,
formats
,
six
from
django.utils.datastructures
import
MultiValueDict
from
django.utils.dates
import
MONTHS
from
django.utils.deprecation
import
(
RemovedInDjango20Warning
,
RenameMethodsBase
,
)
from
django.utils.encoding
import
(
force_str
,
force_text
,
python_2_unicode_compatible
,
)
...
...
@@ -174,7 +177,13 @@ class SubWidget(object):
return
self
.
parent_widget
.
render
(
*
args
)
class
Widget
(
six
.
with_metaclass
(
MediaDefiningClass
)):
class
RenameWidgetMethods
(
MediaDefiningClass
,
RenameMethodsBase
):
renamed_methods
=
(
(
'_format_value'
,
'format_value'
,
RemovedInDjango20Warning
),
)
class
Widget
(
six
.
with_metaclass
(
RenameWidgetMethods
)):
needs_multipart_form
=
False
# Determines does this widget need multipart form
is_localized
=
False
is_required
=
False
...
...
@@ -248,7 +257,7 @@ class Input(Widget):
"""
input_type
=
None
# Subclasses must define this.
def
_
format_value
(
self
,
value
):
def
format_value
(
self
,
value
):
if
self
.
is_localized
:
return
formats
.
localize_input
(
value
)
return
value
...
...
@@ -259,7 +268,7 @@ class Input(Widget):
final_attrs
=
self
.
build_attrs
(
attrs
,
type
=
self
.
input_type
,
name
=
name
)
if
value
!=
''
:
# Only add the 'value' attribute if a value is non-empty.
final_attrs
[
'value'
]
=
force_text
(
self
.
_
format_value
(
value
))
final_attrs
[
'value'
]
=
force_text
(
self
.
format_value
(
value
))
return
format_html
(
'<input{} />'
,
flatatt
(
final_attrs
))
...
...
@@ -443,7 +452,7 @@ class DateTimeBaseInput(TextInput):
super
(
DateTimeBaseInput
,
self
)
.
__init__
(
attrs
)
self
.
format
=
format
if
format
else
None
def
_
format_value
(
self
,
value
):
def
format_value
(
self
,
value
):
return
formats
.
localize_input
(
value
,
self
.
format
or
formats
.
get_format
(
self
.
format_key
)[
0
])
...
...
docs/internals/deprecation.txt
Dosyayı görüntüle @
859eeaa0
...
...
@@ -163,6 +163,8 @@ details on these changes.
* In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a
``parent_link`` will be removed.
* Support for ``Widget._format_value()`` will be removed.
.. _deprecation-removed-in-1.10:
1.10
...
...
docs/ref/forms/widgets.txt
Dosyayı görüntüle @
859eeaa0
...
...
@@ -228,6 +228,17 @@ foundation for custom widgets.
In older versions, this attribute was only defined on the date
and time widgets (as ``False``).
.. method:: format_value(value)
Cleans and returns a value for use in the widget template. ``value``
isn't guaranteed to be valid input, therefore subclass implementations
should program defensively.
.. versionchanged:: 1.10
In older versions, this method is a private API named
``_format_value()``. The old name will work until Django 2.0.
.. method:: id_for_label(self, id_)
Returns the HTML ID attribute of this widget for use by a ``<label>``,
...
...
docs/releases/1.10.txt
Dosyayı görüntüle @
859eeaa0
...
...
@@ -983,6 +983,10 @@ Miscellaneous
* In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a
``parent_link`` is deprecated. Add ``parent_link=True`` to such fields.
* The private API ``Widget._format_value()`` is made public and renamed to
:meth:`~django.forms.Widget.format_value`. The old name will work
through a deprecation period.
.. _removed-features-1.10:
Features removed in 1.10
...
...
tests/forms_tests/field_tests/test_datefield.py
Dosyayı görüntüle @
859eeaa0
...
...
@@ -69,7 +69,7 @@ class DateFieldTest(SimpleTestCase):
'mydate_year'
:
'2008'
,
'mydate_month'
:
'4'
,
'mydate_day'
:
'1'
,
'initial-mydate'
:
HiddenInput
()
.
_
format_value
(
date
(
2008
,
4
,
1
)),
'initial-mydate'
:
HiddenInput
()
.
format_value
(
date
(
2008
,
4
,
1
)),
},
initial
=
{
'mydate'
:
date
(
2008
,
4
,
1
)})
self
.
assertFalse
(
b
.
has_changed
())
...
...
@@ -77,7 +77,7 @@ class DateFieldTest(SimpleTestCase):
'mydate_year'
:
'2008'
,
'mydate_month'
:
'4'
,
'mydate_day'
:
'22'
,
'initial-mydate'
:
HiddenInput
()
.
_
format_value
(
date
(
2008
,
4
,
1
)),
'initial-mydate'
:
HiddenInput
()
.
format_value
(
date
(
2008
,
4
,
1
)),
},
initial
=
{
'mydate'
:
date
(
2008
,
4
,
1
)})
self
.
assertTrue
(
b
.
has_changed
())
...
...
@@ -85,7 +85,7 @@ class DateFieldTest(SimpleTestCase):
'mydate_year'
:
'2008'
,
'mydate_month'
:
'4'
,
'mydate_day'
:
'22'
,
'initial-mydate'
:
HiddenInput
()
.
_
format_value
(
date
(
2008
,
4
,
1
)),
'initial-mydate'
:
HiddenInput
()
.
format_value
(
date
(
2008
,
4
,
1
)),
},
initial
=
{
'mydate'
:
date
(
2008
,
4
,
22
)})
self
.
assertTrue
(
b
.
has_changed
())
...
...
@@ -93,7 +93,7 @@ class DateFieldTest(SimpleTestCase):
'mydate_year'
:
'2008'
,
'mydate_month'
:
'4'
,
'mydate_day'
:
'22'
,
'initial-mydate'
:
HiddenInput
()
.
_
format_value
(
date
(
2008
,
4
,
22
)),
'initial-mydate'
:
HiddenInput
()
.
format_value
(
date
(
2008
,
4
,
22
)),
},
initial
=
{
'mydate'
:
date
(
2008
,
4
,
1
)})
self
.
assertFalse
(
b
.
has_changed
())
...
...
tests/forms_tests/tests/test_input_formats.py
Dosyayı görüntüle @
859eeaa0
This diff is collapsed.
Click to expand it.
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