当前位置: 首页>>代码示例>>Python>>正文


Python widgets.AdminSplitDateTime方法代码示例

本文整理汇总了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',
            }) 
开发者ID:jimmy201602,项目名称:celery-monitor,代码行数:14,代码来源:tests.py

示例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
        ) 
开发者ID:swisscom,项目名称:cleanerversion,代码行数:15,代码来源:admin.py

示例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) 
开发者ID:nesdis,项目名称:djongo,代码行数:4,代码来源:tests.py

示例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) 
开发者ID:nesdis,项目名称:djongo,代码行数:13,代码来源:tests.py

示例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>'
        ) 
开发者ID:nesdis,项目名称:djongo,代码行数:12,代码来源:tests.py

示例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>'
            ) 
开发者ID:nesdis,项目名称:djongo,代码行数:15,代码来源:tests.py


注:本文中的django.contrib.admin.widgets.AdminSplitDateTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。