#11765: models.DateField(null=True, blank=True)  accepts None, but not the empty
string ''
---------------------------------------------------+------------------------
          Reporter:  shmengie                      |         Owner:  nobody
            Status:  new                           |     Milestone:        
         Component:  Database layer (models, ORM)  |       Version:  SVN   
        Resolution:                                |      Keywords:        
             Stage:  Unreviewed                    |     Has_patch:  0     
        Needs_docs:  0                             |   Needs_tests:  1     
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by mrts):

  * version:  1.1 => SVN
  * component:  Uncategorized => Database layer (models, ORM)
  * needs_tests:  0 => 1

Comment:

 The problem is that `DateField.to_python()` (or `DateTimeField`) doesn't
 treat `''` specially, see
 source:/django/trunk/django/db/models/fields/__init__...@10545#l464

 {{{
 class DateTest(models.Model):
     foo = models.DateField(null=True, blank=True)
 }}}

 {{{
 >>> d = DateTest(foo='')
 >>> d.save()
 Traceback (most recent call last):
   ...
   File "/usr/lib/python2.6/dist-
 packages/django/db/models/fields/__init__.py", line 474, in to_python
     _('Enter a valid date in YYYY-MM-DD format.'))
 ValidationError: Enter a valid date in YYYY-MM-DD format.
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11765#comment:2>
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