Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading to Django 1.11.4 ImportError

I'm attempting to upgrade Django from 1.10.7 to 1.11.4 with Python 2.7.11. I've run pip install Django -U and python -c "import django; print django.get_version()" confirms that Django 1.11.4 is installed. However, when I then go to run tests, I get ImportError: No module named notmigrations. Does anyone have any advice?

Here is the full stack trace:

Traceback (most recent call last):
  File "./manage.py", line 25, in <module>
    execute_from_command_line(sys.argv)
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/core/management/commands/test.py", line 29, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/core/management/commands/test.py", line 62, in handle
    failures = test_runner.run_tests(test_labels)
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/test/runner.py", line 601, in run_tests
    old_config = self.setup_databases()
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/test/runner.py", line 546, in setup_databases
    self.parallel, **kwargs
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/test/utils.py", line 187, in setup_databases
    serialize=connection.settings_dict.get('TEST', {}).get('SERIALIZE', True),
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 69, in create_test_db
    run_syncdb=True,
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/core/management/__init__.py", line 130, in call_command
    return command.execute(*args, **defaults)
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 83, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/db/migrations/loader.py", line 52, in __init__
    self.build_graph()
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/db/migrations/loader.py", line 203, in build_graph
    self.load_disk()
  File "/home/vagrant/.virtualenvs/rhw/lib/python2.7/site-packages/django/db/migrations/loader.py", line 82, in load_disk
    module = import_module(module_name)
  File "/usr/local/lib/python2.7.11/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named notmigrations
like image 888
panatale1 Avatar asked Sep 01 '17 14:09

panatale1


2 Answers

It looks like you are using notmigrations in your MIGRATION_MODULES setting to disable migrations (as described in this post).

In Django 1.9+, you should simply use None instead of a fake module name like 'notmigrations' (release notes).

like image 151
Alasdair Avatar answered Oct 26 '22 19:10

Alasdair


For Django 2.0 I create setting file as described here with content like:

from settings import *

class DisableMigrations(object):
    def __contains__(self, item):
        return True

    def __getitem__(self, item):
        return None

MIGRATION_MODULES = DisableMigrations()

and run my tests with test newly created setting

like image 3
andilabs Avatar answered Oct 26 '22 19:10

andilabs