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
186ec21a
Kaydet (Commit)
186ec21a
authored
May 18, 2013
tarafından
Deni Bertovic
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added stripping of whitespace for SlugField and URLField
üst
f54a8880
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
fields.py
django/forms/fields.py
+8
-0
test_extra.py
tests/forms_tests/tests/test_extra.py
+8
-0
No files found.
django/forms/fields.py
Dosyayı görüntüle @
186ec21a
...
...
@@ -670,6 +670,10 @@ class URLField(CharField):
value
=
urlunsplit
(
url_fields
)
return
value
def
clean
(
self
,
value
):
value
=
self
.
to_python
(
value
)
.
strip
()
return
super
(
URLField
,
self
)
.
clean
(
value
)
class
BooleanField
(
Field
):
widget
=
CheckboxInput
...
...
@@ -1105,3 +1109,7 @@ class GenericIPAddressField(CharField):
class
SlugField
(
CharField
):
default_validators
=
[
validators
.
validate_slug
]
def
clean
(
self
,
value
):
value
=
self
.
to_python
(
value
)
.
strip
()
return
super
(
SlugField
,
self
)
.
clean
(
value
)
tests/forms_tests/tests/test_extra.py
Dosyayı görüntüle @
186ec21a
...
...
@@ -569,6 +569,14 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
f
=
GenericIPAddressField
(
unpack_ipv4
=
True
)
self
.
assertEqual
(
f
.
clean
(
' ::ffff:0a0a:0a0a'
),
'10.10.10.10'
)
def
test_slugfield_normalization
(
self
):
f
=
SlugField
()
self
.
assertEqual
(
f
.
clean
(
' aa-bb-cc '
),
'aa-bb-cc'
)
def
test_urlfield_normalization
(
self
):
f
=
URLField
()
self
.
assertEqual
(
f
.
clean
(
'http://example.com/ '
),
'http://example.com/'
)
def
test_smart_text
(
self
):
class
Test
:
if
six
.
PY3
:
...
...
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