本文整理匯總了Python中django.contrib.admin.widgets.AdminDateWidget方法的典型用法代碼示例。如果您正苦於以下問題:Python widgets.AdminDateWidget方法的具體用法?Python widgets.AdminDateWidget怎麽用?Python widgets.AdminDateWidget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.contrib.admin.widgets
的用法示例。
在下文中一共展示了widgets.AdminDateWidget方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _get_form_fields
# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminDateWidget [as 別名]
def _get_form_fields(self):
return OrderedDict(
(
(self.lookup_kwarg_gte, forms.DateField(
label='',
widget=AdminDateWidget(attrs={'placeholder': _('From date')}),
localize=True,
required=False,
initial=self.default_gte,
)),
(self.lookup_kwarg_lte, forms.DateField(
label='',
widget=AdminDateWidget(attrs={'placeholder': _('To date')}),
localize=True,
required=False,
initial=self.default_lte,
)),
)
)
示例2: setUp
# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminDateWidget [as 別名]
def setUp(self):
class TestForm(forms.Form):
char = forms.CharField(max_length=255)
hidden = forms.CharField(max_length=255, widget=forms.HiddenInput())
date = forms.DateField(widget=AdminDateWidget())
datetime = forms.DateTimeField(widget=AdminSplitDateTime())
self.form = TestForm({
'char': 'hi there',
'hidden': 'hidden text',
'date': '20140111',
})
示例3: test_DateField
# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminDateWidget [as 別名]
def test_DateField(self):
self.assertFormfield(Event, 'start_date', widgets.AdminDateWidget)
示例4: test_attrs
# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminDateWidget [as 別名]
def test_attrs(self):
w = widgets.AdminDateWidget()
self.assertHTMLEqual(
w.render('test', datetime(2007, 12, 1, 9, 30)),
'<input value="2007-12-01" type="text" class="vDateField" name="test" size="10">',
)
# pass attrs to widget
w = widgets.AdminDateWidget(attrs={'size': 20, 'class': 'myDateField'})
self.assertHTMLEqual(
w.render('test', datetime(2007, 12, 1, 9, 30)),
'<input value="2007-12-01" type="text" class="myDateField" name="test" size="20">',
)