Makemigrations not working on new install

This one literally has me scratching my head. Working on a project. I’m fairly new to Django. Playing around building out new models and every once in awhile want to erase the database and just start over. I do this by deleting sqllite3 and everything in migrations folders of all apps except for init.py. Then just makemigrations and migrate. Works fine several times. Then I start getting an error on my makemigrations no such table brandprofile__brand. brandprofile is an app and Brand is the only model of that app. Some other models do have a FK relationship with Brand… But of course the table doesn’t exist when I run the command because no tables exist — there is no database at all. This is the initial makemigrations it should be creating all the necessary tables. Double check I did not miss any migration files but can’t figure it out.

Like I said I’ve been deleting and redoing the database a few times so I figure something got corrupted. I create a new virtual environment. Fresh install of django and required modules. Use django-admin to start a new project as well as all new apps. copy over the models views urls admin and forms files. Run makemigrations and get the same error no such table brandprofile__brand.

At this point I’m just going to try and rebuild one app at a time but any insight on what is going on would be appreciated.

You should run your initial migrate before running a makemigrations. Also verify that you still have your migrations directory in your app. You can also try running makemigrations brandprofile.

migrate gave the same error. All folders were there. running makemigrations on any app in the project produced the same error. I finally fixed it by commenting out the brand model then commenting out any admin, function, model, view, or url that referenced it. Of course that had a domino effect on other models that had to have all their references commented out, kind of a PITA. Eventually had a good migrate and added the models back in one at a time until I had a fully working project.