#9721: DateTimeField does not support all DEFAULT_DATETIME_INPUT_FORMATS when
passed a list as input
---------------------------------+------------------------------------------
          Reporter:  uggedal     |         Owner:  nobody                       
    
            Status:  new         |     Milestone:                               
    
         Component:  Forms       |       Version:  SVN                          
    
        Resolution:              |      Keywords:  DateTimeFIeld 
SplitDateTimeWidget
             Stage:  Unreviewed  |     Has_patch:  1                            
    
        Needs_docs:  0           |   Needs_tests:  0                            
    
Needs_better_patch:  0           |  
---------------------------------+------------------------------------------
Changes (by uggedal):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 Until this issue have been resolved or rejected I simply made my own field
 which allows optional time components:

 {{{
 class DateOptionalTimeField(DateTimeField):
     """
     DateTimeField where the time component is optional. To be used with
     SplitDateTimeWidget or a custom MutliWidget. Also see ticket #9721.
     """

     def clean(self, value):
         if isinstance(value, list):
             # Input comes from a SplitDateTimeWidget, for example. So,
 it's two
             # components: date and time.
             if len(value) != 2:
                 raise ValidationError(self.error_messages['invalid'])
             # To support input formats consisting of a date component
 only.
             if value[1] in EMPTY_VALUES:
                 value = value[0]
             else:
                 value = '%s %s' % tuple(value)

         return super(DateOptionalTimeField, self).clean(value)

 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9721#comment:1>
Django <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to