From 8208b07d4f3c1db79d3678f063b9d767ad8b0bcd Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 13 Mar 2014 03:22:04 +0100 Subject: [PATCH] Fix KeyError in _rel_agnostic_fields_ref for uncommon `rel.to` setup django-taggit manually sets up `rel.to` and therefore there is no "to" kwarg. Fixes #22263 Ref: https://github.com/alex/django-taggit/issues/206 --- django/db/migrations/autodetector.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py index cbc4604159cf..076da0ed21fb 100644 --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -71,7 +71,11 @@ def _rel_agnostic_fields_def(fields): for name, field in fields: deconstruction = field.deconstruct()[1:] if field.rel and field.rel.to: - del deconstruction[2]['to'] + try: + del deconstruction[2]['to'] + except KeyError: + # `rel.to` does not have to come from kwargs. + pass fields_def.append(deconstruction) return fields_def