Re: [Django] #11765: models.DateField(null=True, blank=True) accepts None, but not the empty string ''

2021-11-16 Thread Django
#11765: models.DateField(null=True, blank=True)  accepts None, but not the empty
string ''
-+-
 Reporter:  shmengie |Owner:  nobody
 Type:  Uncategorized|   Status:  closed
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  invalid
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by htelsiz):

 same thing happened to me

-- 
Ticket URL: 
Django 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.bccffa453c9bde93630bab01b94b5a93%40djangoproject.com.


Re: [Django] #11765: models.DateField(null=True, blank=True) accepts None, but not the empty string ''

2013-08-07 Thread Django
#11765: models.DateField(null=True, blank=True)  accepts None, but not the empty
string ''
-+-
 Reporter:  shmengie |Owner:  nobody
 Type:  Uncategorized|   Status:  closed
Component:  Database layer   |  Version:  master
  (models, ORM)  |   Resolution:  invalid
 Severity:  Normal   | Triage Stage:
 Keywords:   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by yekibud):

 I got this error using crispy-forms and not specifying my Date field in
 Meta.fields. Adding a clean()n method didn't help but adding the Date
 field back to Meta.fields did.

-- 
Ticket URL: 
Django 
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/066.797b77fa5834448de336908612e1f0aa%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #11765: models.DateField(null=True, blank=True) accepts None, but not the empty string ''

2013-04-11 Thread Django
#11765: models.DateField(null=True, blank=True)  accepts None, but not the empty
string ''
-+-
 Reporter:  shmengie |Owner:  nobody
 Type:  Uncategorized|   Status:  closed
Component:  Database layer   |  Version:  master
  (models, ORM)  |   Resolution:  invalid
 Severity:  Normal   | Triage Stage:
 Keywords:   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Brendan):

 * ui_ux:   => 0
 * type:   => Uncategorized
 * severity:   => Normal
 * easy:   => 0


Comment:

 I agree, I just fixed my problem by adding
 {{{#!python
 def clean(self):
 cleaned_data = super(MyForm, self).clean()
 if not cleaned_data['my_date']:
 cleaned_data['my_date'] = None
 return cleaned_data
 }}}

 to my form. Without this I received the error
 {{{#!python
 ValidationError: [u"'' value has an invalid date format. It must be in
 -MM-DD format."]
 }}}

 even though I had blank=True, null=True set in my model and required=False
 set in my form.

-- 
Ticket URL: 
Django 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #11765: models.DateField(null=True, blank=True) accepts None, but not the empty string ''

2009-10-30 Thread Django
#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 |  
---+
Comment (by tclancy):

 In case it helps anyone else tearing their hair out, here's one other
 thing to check (see [http://stackoverflow.com/questions/1134667/django-
 required-field-in-model-form/1650162#1650162 Stack Overflow ticket]): if
 you have any default or helper text in the field, that will blow up on
 validation before you get to the clean() method.

-- 
Ticket URL: 
Django 
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
-~--~~~~--~~--~--~---



Re: [Django] #11765: models.DateField(null=True, blank=True) accepts None, but not the empty string ''

2009-09-30 Thread Django
#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 |  
---+
Comment (by imbac...@gmail.com):

 i've got the ValidationError exception in django's own create_update
 generic view. a ModelForm instance validates fine, but the save() method
 raises exactly this exception. there's a simple workaround, but IMHO it
 should be performed by the field instance.

 {{{
 #!python
 def clean(self):
 cleaned_data = self.cleaned_data
 end_time = cleaned_data.get('end_time') # this is not None if user
 left the  empty

 # ... do stuff with data

 if not end_time:
 cleaned_data['end_time'] = None

 return cleaned_data
 }}}

 not sure if it warrants a different ticket.

-- 
Ticket URL: 
Django 
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
-~--~~~~--~~--~--~---



Re: [Django] #11765: models.DateField(null=True, blank=True) accepts None, but not the empty string ''

2009-09-05 Thread Django
#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: 
Django 
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
-~--~~~~--~~--~--~---



Re: [Django] #11765: models.DateField(null=True, blank=True) accepts None, but not the empty string ''

2009-09-05 Thread Django
#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 |  
---+
Changes (by iapain):

  * status:  new => closed
  * resolution:  => invalid

Comment:

 blank=True tells user that they don't have to fill this field, and it
 doesn't mean that its empty string. Django assign NoneType if empty.

-- 
Ticket URL: 
Django 
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
-~--~~~~--~~--~--~---



Re: [Django] #11765: models.DateField(null=True, blank=True) accepts None, but not the empty string ''

2009-08-23 Thread Django
#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 -MM-DD format.'))
 ValidationError: Enter a valid date in -MM-DD format.
 }}}

-- 
Ticket URL: 
Django 
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
-~--~~~~--~~--~--~---



Re: [Django] #11765: models.DateField(null=True, blank=True) accepts None, but not the empty string ''

2009-08-23 Thread Django
#11765: models.DateField(null=True, blank=True)  accepts None, but not the empty
string ''
+---
  Reporter:  shmengie   | Owner:  nobody
Status:  new| Milestone:
 Component:  Uncategorized  |   Version:  1.1   
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Changes (by mrts):

  * needs_better_patch:  => 0
  * summary:  models.DateField(null=True, blank=True)  accepts None, but
  not null string '' =>
  models.DateField(null=True, blank=True)
  accepts None, but not the empty string ''
  * needs_tests:  => 0
  * needs_docs:  => 0

-- 
Ticket URL: 
Django 
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
-~--~~~~--~~--~--~---