I was refering to line 187 (and maybe 184 as well):
170 class TimeField(Field):
171 def __init__(self, input_formats=None, *args,
**kwargs):
172 super(TimeField, self).__init__(*args,
**kwargs)
173 self.input_formats = input_formats or
DEFAULT_TIME_INPUT_FORMATS
174
175 def clean(self, value):
176 """
177 Validates that the input can be converted to a
time.
Returns a Python
178 datetime.time object.
179 """
180 super(TimeField, self).clean(value)
181 if value in EMPTY_VALUES:
182 return None
183 if isinstance(value, datetime.time):
184 return value
185 for format in self.input_formats:
186 try:
187 return
datetime.time(*time.strptime(value, format)
[3:6])
188 except ValueError:
189 continue
190 raise ValidationError(gettext(u'Enter a valid
time.'))
On Mar 30, 12:52 pm, "gkelly" <gke... gmail.com> wrote:
> This could be a configuration error on my end, but it
seems to me to
> be a bug (or feature request).
>
> using newforms:
>
> class MyForm(forms.Form):
> time = forms.TimeField(input_formats=('%H:%M',))
>
> I want just an hour:minute field. The input works fine,
but the output
> always outputs %H:%M:%S because the TimeField just
returns a
> datetime.time instance.
>
> Shouldn't it be something like:
>
> return datetime.time(...).strftime(input_formats[0])
>
> so that the output value is a correct input value?
>
> Thanks,
> Grant
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|