From b4f165fe941b1aaca49e417330103a02fecb2e85 Mon Sep 17 00:00:00 2001 From: Stephen Burrows Date: Fri, 21 Mar 2014 00:52:49 -0700 Subject: [1.7.x] Fixed #22300 -- Fixed crash in migrations when changing non-relational field to relational. Backport of 35ed792cf2 from master --- django/db/migrations/autodetector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'django') diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py index 152fde9660..cbd08cc31d 100644 --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -267,7 +267,7 @@ class MigrationAutodetector(object): for rem_app_label, rem_model_name, rem_field_name in (old_fields - new_fields): if rem_app_label == app_label and rem_model_name == model_name: old_field_dec = old_model_state.get_field_by_name(rem_field_name).deconstruct()[1:] - if field.rel and field.rel.to: + if field.rel and field.rel.to and 'to' in old_field_dec[2]: old_rel_to = old_field_dec[2]['to'] if old_rel_to in renamed_models_rel: old_field_dec[2]['to'] = renamed_models_rel[old_rel_to] -- cgit v1.3