#11765: models.DateField(null=True, blank=True) accepts None, but not the empty string '' ---------------------------------------------------+------------------------ Reporter: shmengie | Owner: nobody Status: closed | Milestone: Component: Database layer (models, ORM) | Version: SVN Resolution: invalid | Keywords: Stage: Unreviewed | Has_patch: 0 Needs_docs: 0 | Needs_tests: 1 Needs_better_patch: 0 | ---------------------------------------------------+------------------------ Old description:
> For some reason I cannot create a record with > class MyModel(models.Model): > models.DateField(null=True, blank=True) > MyModel(MyDateField='') It must be either None or a valid date. New description: For some reason I cannot create a record with {{{ class MyModel(models.Model): models.DateField(null=True, blank=True) MyModel(MyDateField='') }}} It must be either None or a valid date. Comment (by kmtracey): Replying to [comment:2 mrts]: > The problem is that `DateField.to_python()` (or `DateTimeField`) doesn't treat `''` specially... Neither does !IntegerField nor !FloatField, eg. It's not clear to me why Date fields would/should be singled out for special treatment here. Forms fields consistently handle treating empty strings input as None, but if you are operating at the model level then you need to use None when you mean None, not an empty string. -- Ticket URL: <http://code.djangoproject.com/ticket/11765#comment:4> 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 django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---