On Tue, Mar 4, 2014 at 8:27 PM, Peter Bengtsson <pete...@gmail.com> wrote:
> I've been googling for an explanation but nothing's come up.
>
> See
> https://github.com/django/django/blob/master/django/forms/fields.py#L447
>
> If you use a `DateField` in your form, don't you expect it to produce a
> `datetime.date` instance?
> E.g.
>
> class MyForm:
>     start = forms.DateField()
>
>     def clean_start(self):
>          if self.cleaned_data['start'] > datetime.date.today():
>             raise ValidationError('too futuristic')
>          return self.cleaned_data['start']
>
> This won't work! You'll get a TypeError if you run that code.
> Why is that?
>
> It'd be easy to fix but because it's so blatant I just suspect I missed
> something obvious.
>

What version of django are you using?

The code linked indicates quite clearly that it should generate a
datetime.date() instance, or raise a ValidationError.

(apologies for double send, tab+space=bad).

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1J17HmqHV60_jHCeyuaKiCxJ5%3DiNUQcGsu1XSHK6r%2BAVA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to