我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用django.forms.SplitDateTimeField()。
def _get_form_fields(self): return OrderedDict(( (self.lookup_kwarg_gte, forms.SplitDateTimeField( label='', widget=AdminSplitDateTime(attrs={'placeholder': _('From date')}), localize=True, required=False )), (self.lookup_kwarg_lte, forms.SplitDateTimeField( label='', widget=AdminSplitDateTime(attrs={'placeholder': _('To date')}), localize=True, required=False )), ))
def add_fields(self, form, index): super(EventOccurrenceCustomFormSet,self).add_fields(form,index) form.fields['startTime'] = forms.SplitDateTimeField(label=_("Start Time"),input_time_formats=['%I:%M%p','%-I:%M%p'], widget=widgets.SplitDateTimeWidget) form.fields['endTime'] = forms.SplitDateTimeField(label=_("End Time"),input_time_formats=['%I:%M%p','%-I:%M%p'], widget=widgets.SplitDateTimeWidget) form.fields['extraOccurrencesToAdd'] = forms.IntegerField(label=_("Repeat __ times:"),initial=0,min_value=0,max_value=100,required=False) form.fields['extraOccurrenceRule'] = forms.ChoiceField(label=_("Every:"),choices=EVENT_REPEAT_CHOICES,required=False) form.fields['sendReminderTo'] = forms.ChoiceField(label=_("Send A Reminder To:"),choices=REMINDER_SET_CHOICES,initial='none',required=False) form.fields['sendReminderWhen'] = forms.ChoiceField(label=_("Before:"),choices=REMINDER_TIME_CHOICES,initial=0,required=False) form.fields['sendReminderWhich'] = forms.ChoiceField(label=_("Ahead Of:"),choices=(('all',_('All Occurrences')),('first',_('First Occurrence Only'))),initial='all',required=False) form.fields['sendReminderGroup'] = forms.ModelChoiceField(label=_("Remind Group:"),queryset=Group.objects.all(),required=False) form.fields['sendReminderUsers'] = forms.ModelMultipleChoiceField(label=_("Remind Users:"),queryset=User.objects.filter(staffmember__isnull=False),required=False)