﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
22263	KeyError: 'to' in MigrationAutodetector with uncommon rel.to setup (django-taggit)	Daniel Hahler	nobody	"I am getting a KeyError exception, when running manage.py migrate a second time on a Django 1.7 project (fresh DB, but migrated from 1.6).

It seems like Django expects a key ""to"" in the field's deconstructor, which is not provided by the deconstructor.

Traceback:
{{{
% manage.py migrate
Operations to perform:
  Synchronize unmigrated apps: djsupervisor, autocomplete_light, reversion, sessions, admin, grappelli, sites, auth, compressor, contenttypes, django_extensions, template_debug, sekizai, django_pdb, crispy_forms
  Apply all migrations: contenttypes, test_duration, taggit
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  No migrations needed.
Traceback (most recent call last):
  File ""/home/user/.virtualenvs/tmm/bin/manage.py"", line 25, in <module>
    execute_from_command_line(sys.argv)
  File ""…/django-master/django/core/management/__init__.py"", line 427, in execute_from_command_line
    utility.execute()
  File ""…/django-master/django/core/management/__init__.py"", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""…/django-master/django/core/management/base.py"", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""…/django-master/django/core/management/base.py"", line 337, in execute
    output = self.handle(*args, **options)
  File ""…/django-master/django/core/management/commands/migrate.py"", line 140, in handle
    changes = autodetector.changes(graph=executor.loader.graph)
  File ""…/django-master/django/db/migrations/autodetector.py"", line 33, in changes
    changes = self._detect_changes()
  File ""…/django-master/django/db/migrations/autodetector.py"", line 84, in _detect_changes
    model_fields_def = _rel_agnostic_fields_def(model_state.fields)
  File ""…/django-master/django/db/migrations/autodetector.py"", line 74, in _rel_agnostic_fields_def
    del deconstruction[2]['to']
KeyError: 'to'
}}}

I have tried to add a testcase for this, but failed - I've stopped when it got too bloated..  :/
There should be one added probably to `tests/migrations/test_autodetector.py`.

I had reported the issue initially at: https://github.com/alex/django-taggit/issues/206"	Bug	closed	Migrations	dev	Normal	invalid		mszamot@…	Accepted	1	0	1	0	0	0
