1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[1.7.x] Fixed #23983 -- Fixed a crash in migrations when adding order_with_respect_to to non-empty table.

Backport of 3dbbb8a89c from master
This commit is contained in:
Andriy Sokolovskiy
2014-12-16 02:22:28 +02:00
committed by Tim Graham
parent 66c0529b3e
commit 10482faf19
3 changed files with 14 additions and 0 deletions

View File

@@ -329,6 +329,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,