mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[1.7.x] Fixed #23405 -- Fixed makemigrations prompt when adding Text/CharField.
A default is no longer required.
Backport of d8f3b86a76 from master
This commit is contained in:
committed by
Tim Graham
parent
4cc646bb56
commit
fdf4dc6cea
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user