python
module_error
ai_generated
true
配置错误:导入迁移模块 django.contrib.admin.migrations 失败:找不到模块 'django.contrib.admin.migrations'
django.core.exceptions.ImproperlyConfigured: Error importing migration module django.contrib.admin.migrations: No module named 'django.contrib.admin.migrations'
ID: python/django-missing-migrations-dir
80%修复率
85%置信度
0证据数
2024-03-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
迁移包目录缺失或损坏,通常由于安装不完整或手动删除导致。
English
The migrations package directory is missing or corrupted, often due to incomplete installation or manual deletion.
解决方案
-
70% 成功率
Reinstall Django: pip install --force-reinstall Django==3.2.0
-
90% 成功率
Create empty __init__.py in each app's migrations directory, then run makemigrations --empty appname
无效尝试
常见但无效的做法:
-
80% 失败
Running migrate again won't recreate missing migration files; it only applies existing migrations.
-
60% 失败
Deleting and recreating the migrations folder manually can cause inconsistency with the database migration history.