[Fixed]-Django: migration x in app x has no Migration class

4πŸ‘

βœ…

As the problem is related to the migration, you have to understand first how it works, django check you database schema compares it with your model then generates the migration script. Every migration script is executed one time, because django keep tracking you migrations. This is managed by a table called django_migrations that is created in your database the first time migrations are ran. So I will suggest two things:

  1. if you have no data in your db, or no important data so I suggest to drop it and create new one then apply all the migrations again
  2. if you have important data, try to look in the django_migrations table and delete the row containing django_comments migrations and most probably the correspondent table, so you can apply the migration again
πŸ‘€Dhia

27πŸ‘

I had this problem, and it turned out that I had accidentally copied a non-migration file into one of my migrations folders. Removing the errant file fixed this for me.

πŸ‘€AlexJerez

2πŸ‘

You are probably using an old version of django-contrib-comments that only supports Django 1.6. It will have South migrations in the migrations/ folder, instead of the new Django migrations.

To fix this, simply upgrade django-contrib-comments:

pip install -U django-contrib-comments
πŸ‘€knbk

0πŸ‘

For me the migration file in question was empty. Deleting it solved my problem

πŸ‘€7guyo

0πŸ‘

I had a file in the migration folder that didn’t belong there. By deleting the misplaced file, I fixed the issue.

πŸ‘€Ramone_Henry

0πŸ‘

  • find the root directory of python in C: drive then delete python and also delete pip.
  • after deleting these both items download the new python and install it again.
πŸ‘€yahya

0πŸ‘

I’ve shared my Django ORM DB model between my custom APP and a Django App via symbolic links: ln -s

0πŸ‘

For me I accidentally put other file(views.py) in migrations directory that cause this error.

Migration X in app X has no Migration class

This mean migrations loader search for class Migration in each py file in migrations directory in case of if migrations class not found then it’ll raise this error

πŸ‘€Kaushal

Leave a comment