#9590: CharField and TextField with blank=True, null=True saves u'' instead of
null
----------------------------------------+-----------------------------------
 Reporter:  romke                       |       Owner:  nobody    
   Status:  new                         |   Milestone:            
Component:  Forms                       |     Version:  1.0       
 Keywords:  charfield, textfield, null  |       Stage:  Unreviewed
Has_patch:  1                           |  
----------------------------------------+-----------------------------------
 Create model and form:
 {{{
 class Test(models.Model):
     testfield = models.CharField(max_length=20, null=True, blank=True)
     testfield2 = models.TextField(null=True, blank=True)
 class NullCharFieldForm(forms.ModelForm):
   class Meta:
     model = Test
     fields = ('testfield', 'testfield2',)
 }}}

 Now create object from POST-alike data (empty input or textarea = ""):
 {{{
 >>> form = NullCharFieldForm({'testfield':'', 'testfield2': ''})
 >>> form.is_valid()
 True
 >>> obj = form.save()
 >>> obj.testfield
 u''
 >>> obj.testfield2
 u''
 }}}

 form validates as it should with blank=True but it stores u"" in object
 fields and in DATABASE :/

 result should be:
 {{{
 >>> obj.testfield
 >>>
 >>> obj.testfield is None
 True
 }}}

 Patch + tests attached, it's created on 1.0.X branch, it passes against
 model_forms and forms (regression) tests.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9590>
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