Monday, November 2, 2015

[1.8] Odd error on makemigrations when moving model to another application

Traceback first:

./manage.py makemigrations
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
    utility.execute()
  File "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 343, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 125, in handle
    migration_name=self.migration_name,
  File "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/db/migrations/autodetector.py", line 43, in changes
    changes = self._detect_changes(convert_apps, graph)
  File "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/db/migrations/autodetector.py", line 110, in _detect_changes
    self.old_apps = self.from_state.concrete_apps
  File "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/db/migrations/state.py", line 170, in concrete_apps
    self.apps = StateApps(self.real_apps, self.models, ignore_swappable=True)
  File "/home/me/.virtualenvs/fluent/local/lib/python2.7/site-packages/django/db/migrations/state.py", line 248, in __init__
    raise ValueError(msg.format(field=operations[0][1], model=lookup_model))
ValueError: Lookup failed for model referenced by field sdd.Documentation.opportunity: sdd.......governance.models.Opportunity

Needless to say, sdd.......governance.models.Opportunity is not a valid path to anything.

The Opportunity model was moved from the sdd application to the governance application. Documentation has a foreign key to Opportunity. The Python itself is correct. It used to be a direct reference to the class in the module, now it's an imported reference. All of the foreign keys are handled in the same way. Nothing is done by string.

I'm ok with a one-off solution for the migration, but I'm more interested in why the model path is so far off and what I might have done to cause it.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d5d6fcf9-8b76-4448-81fb-e38765b66d03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment