3

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?

gasman
  • 23,691
  • 1
  • 38
  • 56
priyanka priya
  • 165
  • 2
  • 9

3 Answers3

6

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.

Paras Jain
  • 393
  • 2
  • 8
  • thanks,it solves but i got reference error after reinstalling django **django.db.migrations.exceptions.NodeNotFoundError: Migration home.0012_auto_20170615_1318 dependencies reference nonexistent parent node ('wagtailimages', '0019_delete_filter')** – priyanka priya Apr 25 '18 at 04:46
  • Did you drop the database? See the edit on my answer above. Please accept the anwer if it helped you. – Paras Jain Apr 26 '18 at 05:30
0

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

0

Just install

pip3 install django-reset-migrations     
Shah Vipul
  • 625
  • 7
  • 11