From 3dbbb8a89ca4beaabd5359fe82e32ed633b15140 Mon Sep 17 00:00:00 2001 From: Andriy Sokolovskiy Date: Tue, 16 Dec 2014 02:22:28 +0200 Subject: Fixed #23983 -- Fixed a crash in migrations when adding order_with_respect_to to non-empty table. --- django/db/migrations/operations/models.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'django') diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py index e92c3d6bd3..d6b6275da3 100644 --- a/django/db/migrations/operations/models.py +++ b/django/db/migrations/operations/models.py @@ -404,6 +404,8 @@ class AlterOrderWithRespectTo(Operation): # it's likely a rename) elif to_model._meta.order_with_respect_to and not from_model._meta.order_with_respect_to: field = to_model._meta.get_field_by_name("_order")[0] + if not field.has_default(): + field.default = 0 schema_editor.add_field( from_model, field, -- cgit v1.3