本文整理汇总了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">',
)