4

I made a new app called 'contact' which I added to installed_apps, but I can't create a table in the SQLite database!

Django version = 3.1

python manage.py makemigrations contact

No changes detected in app 'contact'

then for : python manage.py migrate contact

Operations to perform: Apply all migrations: (none) Running migrations: No migrations to apply.

I have tried many solutions proposed by members here but None worked

like checking "init" file existed in migrations folder and it's empty or commands like these :

python manage.py migrate --fake contact zero

Operations to perform: Unapply all migrations: contact Running migrations: No migrations to apply.

python manage.py migrate contact --fake-initial

Operations to perform: Apply all migrations: (none) Running migrations: No migrations to apply.

mr.m
  • 312
  • 4
  • 15
  • Junior Django developer here: Have you tried running "python manage.py makemigrations"? Instead of specifying which model you are trying to migrate. Also, have you written any models on Contact.models.py file? – Kamarul Adha Aug 30 '20 at 20:20
  • yes, I have tried this before adding app name – mr.m Aug 31 '20 at 02:46

2 Answers2

13

This worked for me;

python manage.py makemigrations --empty yourappname

python manage.py migrate yourappname

It turns out adding an extra empty migration forces django to recheck the table and in the process, it noticed the new migrations. There's probably some caching taking place somewhere.

Original answer

karuhanga
  • 3,010
  • 1
  • 27
  • 30
mr.m
  • 312
  • 4
  • 15
-1

Try not to use the name of your app.

Eg.

python manage.py makemigrations

python manage.py migrate

If don't work. You can do something more risky. Go to the directory of your project. Take the database to another folder. Make the same above commands.

southernegro
  • 384
  • 4
  • 20