pythondjangomigrationmakemigrations

Migrations in DJango


I am having DJango migrations problem while making migration following error is coming.

enter image description here

enter image description here

enter image description here

When I run my applications using python manage.py runserver it shows this :-

enter image description here

However, running python manage.py makemigrations shows no changes detected And Above three images are result after running python manage.py migrate. What is the problem with this?


Solution

  • When the *table> already exists Error happens, it is usually due to deleting and rerunning the initial migration or models.py file. For these scenarios,

    python manage.py makemigrations <app_name>
    python manage.py migrate --fake-initial <app_name>
    

    Or if you want to fake only one migration file

    python manage.py migrate <migration_file_number> --fake <app_name>
    

    --fake-initial tells Django to mark initial migration as migrated without actually running its corresponding SQL.

    Django's migration document may be helpful