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
2d7c27d3
Kaydet (Commit)
2d7c27d3
authored
Şub 09, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #24302 -- Added DurationField.formfield()
üst
32ed4c20
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
__init__.py
django/db/models/fields/__init__.py
+7
-0
test_durationfield.py
tests/model_fields/test_durationfield.py
+9
-0
No files found.
django/db/models/fields/__init__.py
Dosyayı görüntüle @
2d7c27d3
...
...
@@ -1689,6 +1689,13 @@ class DurationField(Field):
val
=
self
.
_get_val_from_obj
(
obj
)
return
''
if
val
is
None
else
duration_string
(
val
)
def
formfield
(
self
,
**
kwargs
):
defaults
=
{
'form_class'
:
forms
.
DurationField
,
}
defaults
.
update
(
kwargs
)
return
super
(
DurationField
,
self
)
.
formfield
(
**
defaults
)
class
EmailField
(
CharField
):
default_validators
=
[
validators
.
validate_email
]
...
...
tests/model_fields/test_durationfield.py
Dosyayı görüntüle @
2d7c27d3
import
datetime
import
json
from
django
import
forms
from
django.core
import
exceptions
,
serializers
from
django.db
import
models
from
django.test
import
TestCase
...
...
@@ -70,3 +71,11 @@ class TestValidation(TestCase):
"'not a datetime' value has an invalid format. "
"It must be in [DD] [HH:[MM:]]ss[.uuuuuu] format."
)
class
TestFormField
(
TestCase
):
# Tests for forms.DurationField are in the forms_tests app.
def
test_formfield
(
self
):
field
=
models
.
DurationField
()
self
.
assertIsInstance
(
field
.
formfield
(),
forms
.
DurationField
)
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