diff options
| author | Andriy Sokolovskiy <sokandpal@yandex.ru> | 2014-12-06 22:43:19 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-12-15 14:58:01 -0500 |
| commit | fdf4dc6cea0cdfea061f2d72a368adf6a8d24157 (patch) | |
| tree | 1aff2e4b367bda814477ced2bda596fc14a65b8b /django | |
| parent | 4cc646bb56693c8068044ed3b8d5eeb69adde088 (diff) | |
[1.7.x] Fixed #23405 -- Fixed makemigrations prompt when adding Text/CharField.
A default is no longer required.
Backport of d8f3b86a7691c8aa0ec8f5a064ad4c3218250fed from master
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/migrations/autodetector.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py index 23ab3797e4..99951cdae5 100644 --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -802,8 +802,11 @@ class MigrationAutodetector(object): None, True )) - # You can't just add NOT NULL fields with no default - if not field.null and not field.has_default() and not isinstance(field, models.ManyToManyField): + # You can't just add NOT NULL fields with no default or fields + # which don't allow empty strings as default. + if (not field.null and not field.has_default() and + not isinstance(field, models.ManyToManyField) and + not (field.blank and field.empty_strings_allowed)): field = field.clone() field.default = self.questioner.ask_not_null_addition(field_name, model_name) self.add_operation( |
