0

I'm new in Django. Here is how I do:

  1. Create app by : python manager.py startap test
  2. and I add several models,

then execute:

  1. python manager.py makemigrations
  2. python manager migrate

It will generate tables automatically. Then I dropped the table in database by:

  1. drop table table_name

execute again:

  1. python manager.py makemigrations
  2. python manager.py migrate

But there is no table generated in database, and I got the message "no changes detected". How should I do to have these table?

ZF007
  • 3,708
  • 8
  • 29
  • 48
TreeCatCat
  • 143
  • 1
  • 1
  • 12
  • 4
    Django keeps a migrations table in your database to keep track of what migration you're on, so if you manipulate the database directly (without Django) and don't manipulate Django's own state tracking, it will get confused. Just drop the migrations table and regenerate your database with makemigrations and try to use `manage.py` to manipulate the database in the future. – Two-Bit Alchemist Aug 29 '16 at 01:04
  • 1
    Why do you want to regenerate your tables? Have you made changes to your models or are you trying to clear out the data in the tables? The idea of "regenerating" a single table in a django app does not seem right to me. I think reading this post may help: http://stackoverflow.com/q/26713231/784648 – A. J. Parr Aug 29 '16 at 03:45

1 Answers1

0

Delete all the migration file in your app's migrations directory. Then run

python makemigrations your_app 
python migrate
Harry Moreno
  • 10,231
  • 7
  • 64
  • 116
Windsooon
  • 6,864
  • 4
  • 31
  • 50