Updating Django - error: 'No module named migration'
As @YPCrumble pointed out, your ">> Deleting old migrations" script deleted /django/db/migrations/
file as well. To restore it back, you need to uninstall Django and reinstall it.
If your error still like :
from .migration import Migration, swappable_dependency # NOQA
ImportError: No module named 'django.db.migrations.migration'
You need to reinstall dajngo
Check You Django version and then Force Reinstall it
python -m django --version
pip install --upgrade --force-reinstall package
pip install --upgrade --force-reinstall Django==2.0.5
Just reinstall the django version or upgrade the version. This solves my problem.
pip install --upgrade django==1.11.18
Then makemigrations
Your script appears to be the problem. It is trying to delete your migrations, but it's actually also deleting the contents of Django's /django/db/migrations/
file as well. Note that it explicitly doesn't delete the __init__.py
file but it does delete the others.
One option is just to remove these lines:
echo ">> Deleting old migrations"
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
find . -path "*/migrations/*.pyc" -delete
You shouldn't be deleting old migrations anyway once you're running Django on production because you might want to add custom code to a migration. This looks like a convenience script for development.