priyanka priya
priyanka priya

Reputation: 165

Python-ModuleNotFoundError: No module named 'django.db.migrations.migration'

I got this error ModuleNotFoundError: No module named 'django.db.migrations.migration' after i tried these below steps

  1. python3 manage.py migrate --fake resources zero (resources is my app name)
  2. find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
  3. find . -path "*/migrations/*.pyc" -delete
  4. python3 manage.py showmigrations

Note: used PostgreSQL

How to resolve this issue?

Upvotes: 3

Views: 7842

Answers (3)

Shah Vipul
Shah Vipul

Reputation: 747

Just install

pip3 install django-reset-migrations     

Upvotes: 0

Paras Jain
Paras Jain

Reputation: 393

By running those commands you might have accidentally deleted the migrations module. Try reinstalling Django via pip. pip uninstall django pip install django

Take note of the version of Django you are using. In case you aren't using the latest version for your python environment install using the following command pip install django==<version goes here>

Edit:-

Drop the existing database schema. Delete the migrations folder and recreate an empty one in its place.

Upvotes: 6

It seems you need to force reinstall Django in order to restore the base migrations folder.

Upvotes: 0

Related Questions