本文整理匯總了Python中django.forms.SplitDateTimeWidget方法的典型用法代碼示例。如果您正苦於以下問題:Python forms.SplitDateTimeWidget方法的具體用法?Python forms.SplitDateTimeWidget怎麽用?Python forms.SplitDateTimeWidget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.forms
的用法示例。
在下文中一共展示了forms.SplitDateTimeWidget方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import SplitDateTimeWidget [as 別名]
def __init__(self, attrs=None):
widgets = [AdminDateWidget, AdminTimeWidget]
# Note that we're calling MultiWidget, not SplitDateTimeWidget, because
# we want to define widgets.
forms.MultiWidget.__init__(self, widgets, attrs)
示例2: test_constructor_attrs
# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import SplitDateTimeWidget [as 別名]
def test_constructor_attrs(self):
widget = SplitDateTimeWidget(attrs={'class': 'pretty'})
self.check_html(widget, 'date', datetime(2006, 1, 10, 7, 30), html=(
'<input type="text" class="pretty" value="2006-01-10" name="date_0">'
'<input type="text" class="pretty" value="07:30:00" name="date_1">'
))
示例3: test_constructor_different_attrs
# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import SplitDateTimeWidget [as 別名]
def test_constructor_different_attrs(self):
html = (
'<input type="text" class="foo" value="2006-01-10" name="date_0">'
'<input type="text" class="bar" value="07:30:00" name="date_1">'
)
widget = SplitDateTimeWidget(date_attrs={'class': 'foo'}, time_attrs={'class': 'bar'})
self.check_html(widget, 'date', datetime(2006, 1, 10, 7, 30), html=html)
widget = SplitDateTimeWidget(date_attrs={'class': 'foo'}, attrs={'class': 'bar'})
self.check_html(widget, 'date', datetime(2006, 1, 10, 7, 30), html=html)
widget = SplitDateTimeWidget(time_attrs={'class': 'bar'}, attrs={'class': 'foo'})
self.check_html(widget, 'date', datetime(2006, 1, 10, 7, 30), html=html)
示例4: test_formatting
# 需要導入模塊: from django import forms [as 別名]
# 或者: from django.forms import SplitDateTimeWidget [as 別名]
def test_formatting(self):
"""
Use 'date_format' and 'time_format' to change the way a value is
displayed.
"""
widget = SplitDateTimeWidget(
date_format='%d/%m/%Y', time_format='%H:%M',
)
self.check_html(widget, 'date', datetime(2006, 1, 10, 7, 30), html=(
'<input type="text" name="date_0" value="10/01/2006">'
'<input type="text" name="date_1" value="07:30">'
))