﻿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
32799	Inconsistency regarding the default value of CharField	Adam Sołtysik	nobody	"Let's assume I want to add a `CharField` to a model:

{{{
class Test(Model):
    # other fields
    name = CharField(max_length=20)
}}}

This field is non-nullable and has no default value. However, when an object is created, the field gets an empty string automatically:

{{{
>>> Test().name
''
}}}

When such an object is saved, an empty string will be saved to the database. The same happens when I call `Test.objects.create()`.

On the other hand, when I create a migration, Django asks me to provide a default. If I omit a default value and try to execute the migration, there will be `IntegrityError` due to the `NOT NULL` constraint.

So the question is: why does `CharField` behave differently in the contexts of Python objects and migrations? The same goes also for `FileField`, but not e.g. for non-nullable `IntegerField` (it won't get a value of `0` automatically).

Changing the behaviour of objects with `CharField` would be a breaking change, but for consistency, I think that migrations should also infer the empty string as the default value, even when there is no `default=''` or `blank=True`.

Possibly related: #23405.

"	New feature	closed	Migrations	3.2	Normal	wontfix			Unreviewed	0	0	0	0	0	0
