﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
9590	CharField and TextField with blank=True, null=True saves u'' instead of null	Roman Barczyński	nobody	"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."	Uncategorized	closed	Database layer (models, ORM)	1.0	Normal	wontfix	charfield, textfield, null		Unreviewed	1	0	0	1	0	0
