﻿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
36286	if I specify `null=False, blank=False` in a `models.TextField`, django should not generate a blank string for me	bwo		"Suppose I have an existing model `M` with integer-valued fields `a` and `b` and somewhere in my test code I do this: `M.objects.create(a=1, b=2)`.

Now I create add a new non-nullable string-valued field by altering M's definition like so:

{{{

class Choices(models.TextChoices):
    one = (""one"", ""one"")
    two = (""two"", ""two"")

class M(models.Model):
    # existing fields omitted
    c = models.TextField(null=False, choices=Choices.choices)
}}}

I add some code that switches on the value of `c`, knowing that it will certainly be either ""one"" or ""two"" (even though django actually does no validation here…). I run tests, confident in the knowledge that either Django or the database will complain at every site that doesn't set a value for `c`.

In fact, this doesn't happen. The value of `c`, if not provided, generated and set to `''`. This behavior by itself strikes me as a bug: if I wanted it to be ok to not provide a value for `c`, I wouldn't have made it non-nullable. But fine, let's add a `blank=False` (eve though this parameter is apparently related to forms) to the definition and try again.

It's still `''`!"	Bug	closed	Database layer (models, ORM)	dev	Normal	invalid			Unreviewed	0	0	0	0	0	0
