#21397: forms.TypedChoiceField validation problem
-------------------------------+--------------------
     Reporter:  Elec           |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Forms          |    Version:  1.6
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 I get ValidationError on this code:

 {{{
 POST_DAYS_CHOICE = (
     (7, '1 week'),
     (14, '2 weeks'),
     (30, '1 month'),
     (60, '2 months'),
     (90, '3 months'),
 )

 def days_to_till_date(val):
     print val
     try:
         till_date = date.today() + timedelta(int(val))
     except ValueError:
         till_date = date.today() + timedelta(30)
     return till_date

 class PostForm(forms.ModelForm):
     till_date = forms.TypedChoiceField(label='Period',
 choices=POST_DAYS_CHOICE, coerce=days_to_till_date, required=True,
 initial=30)

 }}}

 This is was removed from TypedChoiceField class:

 {{{
     def validate(self, value):
         pass
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21397>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/047.8c38f9a7e455dcb25b30be802fc44c11%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to