I was trying to create migrations within an existing app using the makemigrations command but it outputs \"No changes detected\".
Usually I create new apps using the
I solved that problem by doing this:
One more edge case and solution:
I added a boolean field, and at the same time added an @property referencing it, with the same name (doh). Commented the property and migration sees and adds the new field. Renamed the property and all is good.
My problem with this error, was that I had included:
class Meta:
abstract = True
Inside model that I wanted to creation migrate for.
The solution is you have to include your app in INSTALLED_APPS.
I missed it and I found this same issue.
after specifying my app name migration became successful
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'boards',
]
please note I mentioned boards in last, which is my app name.
The Best Thing You can do is, Delete the existing database. In my case, I were using phpMyAdmin SQL database, so I manually delete the created database overthere.
After Deleting: I create database in PhpMyAdmin, and doesn,t add any tables.
Again run the following Commands:
python manage.py makemigrations
python manage.py migrate
After These Commands: You can see django has automatically created other necessary tables in Database(Approx there are 10 tables).
python manage.py makemigrations <app_name>
python manage.py migrate
And Lastly: After above commands all the model(table) you have created are directly imported to the database.
Hope this will help.
There are sometimes when ./manage.py makemigrations
is superior to ./manage.py makemigrations <myapp>
because it can handle certain conflicts between apps.
Those occasions occur silently and it takes several hours of swearing
to understand the real meaning of the dreaded No changes detected
message.
Therefore, it is a far better choice to make use of the following command:
./manage.py makemigrations <myapp1> <myapp2> ... <myappN>