本文整理匯總了Python中django.contrib.admin.widgets.AdminSplitDateTime方法的典型用法代碼示例。如果您正苦於以下問題:Python widgets.AdminSplitDateTime方法的具體用法?Python widgets.AdminSplitDateTime怎麽用?Python widgets.AdminSplitDateTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.contrib.admin.widgets
的用法示例。
在下文中一共展示了widgets.AdminSplitDateTime方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setUp
# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminSplitDateTime [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',
})
示例2: __init__
# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminSplitDateTime [as 別名]
def __init__(self, request, *args, **kwargs):
field_name = kwargs.pop('field_name')
super(DateTimeFilterForm, self).__init__(*args, **kwargs)
self.request = request
self.fields['%s_as_of' % field_name] = forms.SplitDateTimeField(
label='',
input_time_formats=['%I:%M %p', '%H:%M:%S'],
widget=AdminSplitDateTime(
attrs={'placeholder': 'as of date and time'}
),
localize=True,
required=True
)
示例3: test_DateTimeField
# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminSplitDateTime [as 別名]
def test_DateTimeField(self):
self.assertFormfield(Member, 'birthdate', widgets.AdminSplitDateTime)
示例4: test_formfield_overrides_for_datetime_field
# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminSplitDateTime [as 別名]
def test_formfield_overrides_for_datetime_field(self):
"""
Overriding the widget for DateTimeField doesn't overrides the default
form_class for that field (#26449).
"""
class MemberAdmin(admin.ModelAdmin):
formfield_overrides = {DateTimeField: {'widget': widgets.AdminSplitDateTime}}
ma = MemberAdmin(Member, admin.site)
f1 = ma.formfield_for_dbfield(Member._meta.get_field('birthdate'), request=None)
self.assertIsInstance(f1.widget, widgets.AdminSplitDateTime)
self.assertIsInstance(f1, forms.SplitDateTimeField)
示例5: test_render
# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminSplitDateTime [as 別名]
def test_render(self):
w = widgets.AdminSplitDateTime()
self.assertHTMLEqual(
w.render('test', datetime(2007, 12, 1, 9, 30)),
'<p class="datetime">'
'Date: <input value="2007-12-01" type="text" class="vDateField" '
'name="test_0" size="10"><br>'
'Time: <input value="09:30:00" type="text" class="vTimeField" '
'name="test_1" size="8"></p>'
)
示例6: test_localization
# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminSplitDateTime [as 別名]
def test_localization(self):
w = widgets.AdminSplitDateTime()
with self.settings(USE_L10N=True), translation.override('de-at'):
w.is_localized = True
self.assertHTMLEqual(
w.render('test', datetime(2007, 12, 1, 9, 30)),
'<p class="datetime">'
'Datum: <input value="01.12.2007" type="text" '
'class="vDateField" name="test_0"size="10"><br>'
'Zeit: <input value="09:30:00" type="text" class="vTimeField" '
'name="test_1" size="8"></p>'
)