django: migration x in app x has no Migration class

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.


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