(dev3)knbk@dev-vm:~/projects/django18-migration-bug$ manage migrate
Operations to perform:
  Synchronize unmigrated apps: messages, staticfiles
  Apply all migrations: auth, contenttypes, debug, admin, sessions
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  No migrations to apply.
Traceback (most recent call last):
  File "/home/knbk/projects/dev/django/django/apps/config.py", line 159, in get_model
    return self.models[model_name.lower()]
KeyError: 'spam'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/knbk/projects/dev/django/django/db/migrations/state.py", line 226, in __init__
    model = self.get_model(lookup_model[0], lookup_model[1])
  File "/home/knbk/projects/dev/django/django/apps/registry.py", line 202, in get_model
    return self.get_app_config(app_label).get_model(model_name.lower())
  File "/home/knbk/projects/dev/django/django/apps/config.py", line 162, in get_model
    "App '%s' doesn't have a '%s' model." % (self.label, model_name))
LookupError: App 'debug' doesn't have a 'spam' model.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/knbk/projects/dev/django/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/knbk/projects/dev/django/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/knbk/projects/dev/django/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/knbk/projects/dev/django/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/home/knbk/projects/dev/django/django/core/management/commands/migrate.py", line 207, in handle
    changes = autodetector.changes(graph=executor.loader.graph)
  File "/home/knbk/projects/dev/django/django/db/migrations/autodetector.py", line 43, in changes
    changes = self._detect_changes(convert_apps, graph)
  File "/home/knbk/projects/dev/django/django/db/migrations/autodetector.py", line 110, in _detect_changes
    self.old_apps = self.from_state.concrete_apps
  File "/home/knbk/projects/dev/django/django/db/migrations/state.py", line 158, in concrete_apps
    self.apps = StateApps(self.real_apps, self.models, ignore_swappable=True)
  File "/home/knbk/projects/dev/django/django/db/migrations/state.py", line 236, in __init__
    raise ValueError(msg.format(field=operations[0][1], model=lookup_model))
ValueError: Lookup failed for model referenced by field debug.John.consumed_food: debug.Spam