Django Update - Error: "There is no module named" migration "

I am updating my Django application from Django 1.5.5 tot 1.9, Django-cms from 2.4.3 to 3.3 (and all related packages).

After I plowed all the errors of the depreciable functions, I now stumble on an error that I cannot understand: "There is no module named" migration "

I get this error on startup (in virtualenv): - python manage.py runningerver and also when I run - python manage.py migrate

Traceback (most recent call last):
  File "manage.py", line 20, in <module>
    execute_from_command_line(sys.argv)
  File "/var/www/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/var/www/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/www/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 195, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/var/www/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 39, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/var/www/env/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 16, in <module>
    from django.db.migrations.autodetector import MigrationAutodetector
  File "/var/www/env/local/lib/python2.7/site-packages/django/db/migrations/__init__.py", line 1, in <module>
    from .migration import Migration, swappable_dependency  # NOQA
ImportError: No module named migration

manage.py

#!/usr/bin/env python2
import os
import sys

if __name__ == "__main__":

    settings_module_path = 'ais.settings.production'
    ########## Attempt to override settings using local settings
    try:
        from ais.settings.local_settings import *
        # For developmentent, file will probably hold the following:
        settings_module_path = 'ais.settings.development'
        print "!!!manage.py settings overwritten!!!"
    except ImportError:
        pass
    os.environ['DJANGO_SETTINGS_MODULE'] = settings_module_path

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

migrate.sh

#!/bin/sh
echo "Starting ..."

echo ">> Deleting old migrations"
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
find . -path "*/migrations/*.pyc"  -delete


# Optional
echo ">> Deleting sqlite  (if exists) database"
find . -name "db.sqlite3" -delete

echo ">> Running manage.py makemigrations"
python manage.py makemigrations

echo ">> Running manage.py migrate"
python manage.py migrate

echo ">> Done"
+6
source share
5 answers

, script . , Django /django/db/migrations/. , __init__.py, .

- :

echo ">> Deleting old migrations" 
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete 
find . -path "*/migrations/*.pyc"  -delete

, Django , . script .

+10

:

 from .migration import Migration, swappable_dependency  # NOQA
ImportError: No module named 'django.db.migrations.migration'

Django,

python -m django --version

pip install --upgrade --force-

  pip install --upgrade --force-reinstall  Django==2.0.5
+6

@YPCrumble, ">> " /django/db/migrations/ file. , Django .

+1

Django . . , , , .

Class User(models.Model):
    username = models.CharField(max_length=255)

    Class Meta:
        manage = False
        manage = True
  • .
  • ( ).
  • .
  • .
  • .
0

Django . .

pip install --upgrade django==1.11.18

0
source

Source: https://habr.com/ru/post/1675295/


All Articles