Невозможно установить Django миграций в правильном порядке. - PullRequest
0 голосов
/ 27 марта 2020

Я добавил новое приложение «портфолио» в свой проект, но с тех пор миграции больше не будут работать, потому что Django, кажется, пытается сделать их в неправильном порядке.

Running migrations:
Applying core.0001_initial... OK
Applying contenttypes.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0001_initial... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying user.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying data.0001_initial... OK
Applying data.0002_auto_20200306_1522...Traceback (most recent call last):
File "/opt/miniconda3/envs/cert_tool/lib/python3.7/site-packages/django/apps/registry.py", line 155, in get_app_config

  return self.app_configs[app_label]

KeyError: 'portfolio'

During handling of the above exception, another exception occurred:

[...]

LookupError: No installed app with label 'portfolio'.

портфолио указан в моем INSTALLED_APPS:

LOCAL_APPS = (
    'core',
    'portfolio',
    'user',
    'data',
    'editor',
)

INSTALLED_APPS = DJANGO_APPS + LOCAL_APPS + THIRD_PARTY_APPS

Если я добавлю зависимость в проблемную миграцию c data.0002_auto_20200306_1522:

class Migration(migrations.Migration):
    dependencies = [
        ('data', '0001_initial'),
        ('portfolio', '0001_initial'),
    ]

Другие ошибки:

django.db.migrations.exceptions.NodeNotFoundError: Migration data.0002_auto_20200306_1522 dependencies reference nonexistent parent node ('portfolio', '0001_initial')

Traceback (most recent call last):

  File "/opt/miniconda3/envs/cert_tool/lib/python3.7/site-packages/django/db/migrations/loader.py", line 166, in check_key

    return self.graph.root_nodes(key[0])[0]

IndexError: list index out of range

During handling of the above exception, another exception occurred:

[...]

File "/opt/miniconda3/envs/cert_tool/lib/python3.7/site-packages/django/db/migrations/loader.py", line 173, in check_key

    raise ValueError("Dependency on app with no migrations: %s" % key[0])

ValueError: Dependency on app with no migrations: user

Я получаю те же результаты с 'run_before'

Единственный способ заставить все работать снова - это сначала явно перенести портфель:

migrate portfolio
migrate

Любая помощь будет очень большой оценил!

Спасибо!

...