Aaryan Rawat
Aaryan Rawat

Reputation: 5

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?

Upvotes: 0

Views: 1235

Answers (2)

OZahed
OZahed

Reputation: 493

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

Upvotes: 0

Sefi R
Sefi R

Reputation: 110

looks like you changed the database or migration files manually. try to re-create the database.

  1. delete the DB file
  2. delete all migrations files (keep the init file)
  3. run create migrations command
  4. run migrate command

Upvotes: 0

Related Questions