Esempio n. 1
0
 def _get_form_fields(self):
     return OrderedDict((
         (self.lookup_kwarg_gte,
          forms.DateField(
              label='',
              widget=AdminDateWidget(attrs={'placeholder': _('From date')}),
              localize=True,
              required=False)),
         (self.lookup_kwarg_lte,
          forms.DateField(
              label='',
              widget=AdminDateWidget(attrs={'placeholder': _('To date')}),
              localize=True,
              required=False)),
     ))
    def __init__(self, *args, **kwargs):
        field_name = kwargs.pop('field_name')
        super(DateRangeForm, self).__init__(*args, **kwargs)

        self.fields['%s%s__gte' %
                    (FILTER_PREFIX, field_name)] = forms.DateField(
                        label='',
                        widget=AdminDateWidget(
                            attrs={'placeholder': _('From date')}),
                        localize=True,
                        required=False)

        self.fields['%s%s__lte' %
                    (FILTER_PREFIX, field_name)] = forms.DateField(
                        label='',
                        widget=AdminDateWidget(
                            attrs={'placeholder': _('To date')}),
                        localize=True,
                        required=False,
                    )