diff options
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( |
