Opened 11 years ago

Closed 10 years ago

#22263 closed Bug (invalid)

KeyError: 'to' in MigrationAutodetector with uncommon rel.to setup (django-taggit)

Reported by: Daniel Hahler Owned by: nobody
Component: Migrations Version: dev
Severity: Normal Keywords:
Cc: mszamot@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

Change History (5)

comment:1 by Daniel Hahler, 11 years ago

Needs tests: set

Here is a pull request: https://github.com/django/django/pull/2426

NOTE: I am not sure, if this is a bug with django-taggit instead, which should have returned to in its deconstruction (since it has rel.to setup).

comment:2 by Marcin Szamotulski <mszamot@…>, 11 years ago

Cc: mszamot@… added

I can reproduce it here, and indeed this will fix the problem.

comment:3 by Aymeric Augustin, 11 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Tim Graham, 11 years ago

Easy pickings: unset

comment:5 by Markus Holtermann, 10 years ago

Resolution: invalid
Status: newclosed

This issue was django-taggit related and not a problem in Django itself. Has been fixed in https://github.com/alex/django-taggit/pull/207

Note: See TracTickets for help on using tickets.
Back to Top